Recent Topics

1 Jul 29, 2008 10:26    

It would be great to see this option in future releases
There are only 6 predefined resize options now :(

This is a temporary hack if you don't want to wait ;)

How to use:
Instead of fit-320x320 use custom-320x320,80 which means WIDTH HEIGHT QUALITY

Put this code in inc/files/model/_file.class.php (b2evo-2.4.2 line 1747)

if( preg_match('/^custom-(.*?)x(.*?),(.*?)$/', $req_size, $matches) )
{	// Use custom sizes
	$thumb_width = $matches[1];
	$thumb_height = $matches[2];
	$thumb_quality = $matches[3];
	$size_name = $req_size;
}

2 Jul 30, 2008 01:34

Unless I'm wrong in thinking, I can now tell it "480x10000000,90" so that an image that is done portrait style doesn't get limited to 320 tall (and therefore 240 wide) when what I want is the width to fit.

Limiting the height of an image makes no sense at all. Kinda like the file and renaming structure for refits eh?

Correct me if I'm wrong, but when I add this code to the identified file then in my skin I would tell it

skin_include( '_item_content.inc.php', array(
		'image_size'	=>	'custom-480x1000000,90',
	) );

Oh and the file is actually inc/files/model/_file.class.php (not files.class is what I mean).

Cool. Thanks!

3 Jul 30, 2008 02:29

Fixed files, thanks

You're right, it probably uses the lowest number as a limit to save image proportions. This is how avatars plugin works also.
I didn't check the code, there might be another rezising method.

4 Jul 30, 2008 06:55

One more thing, there should be a maximum value for one parameter.

if( preg_match('/^custom-(.*?)x(.*?),(.*?)$/', $req_size, $matches) )
{    // Use custom sizes
    $thumb_width = $matches[1];
    $thumb_height = $matches[2];
    $thumb_quality = $matches[3];
    $size_name = $req_size;
    
    if( $thumb_width > 2000 )
          $thumb_width = 2000;   
}

EDIT: never mind it doesn't generate thumbs larger than the original image.

5 Aug 16, 2008 11:27

sam2kb can you clarify something for me? When you say "add this at line 1747" what *exactly* does that mean? Like, can you show me "find these 4 lines then replace them with these 11 lines"? My concern is that (a) I don't logically see what you're doing at line 1747 in my file and (b) I don't really know if you mean before or after the current line 1747 and (c) line numbers don't mean nothing when other core hacks might exist.

Because if it was me I'd have added a new case to the switch( $req_size ) bit. When I look at line 1747 I see "if( !empty( $err ) )" which sort of sounds like it's too late to make a resize because now we're talking about what to do if we have an error.

Mean while I'll just randomly guess at it.

EDIT: or maybe it belongs before the last line of this bit:

				$thumb_quality = 75;
		}

		$mimetype = $this->Filetype->mimetype;


That way after falling through to the default but before anything actually happens it'll say "oh yeah I match this custom bit so I'll do what it tells me".

6 Aug 16, 2008 14:51

I don't remember why I didn't put it inside the switch, you can try to put it in.

    case 'fit-80x80';
	default:
		$size_name = 'fit-80x80';
		$thumb_width = 80;
		$thumb_height = 80;
		$thumb_quality = 75;
}

if( preg_match('/^custom-(.*?)x(.*?),(.*?)$/', $req_size, $matches) )
{	// Use custom sizes
	$thumb_width = $matches[1];
	$thumb_height = $matches[2];
	$thumb_quality = $matches[3];
	$size_name = $req_size;
}

$mimetype = $this->Filetype->mimetype;

// Try to output the cached thumbnail:
$err = $this->output_cached_thumb( $size_name, $mimetype );

7 Aug 16, 2008 17:56

Silly question ... why don't you change custom- to fit- and then bin the whole switch palaver and just use your regex ?

¥

8 Aug 16, 2008 20:21

¥åßßå wrote:

Silly question ... why don't you change custom- to fit- and then bin the whole switch palaver and just use your regex ?

This should work also

$size_name = $req_size;
switch( $req_size )
{	
	case preg_match('/^fit-(.*?)x(.*?),(.*?)$/', $req_size, $matches); // fit-100x100,90
		$thumb_width = $matches[1];
		$thumb_height = $matches[2];
		$thumb_quality = $matches[3];
		break;
	
	case preg_match('/^fit-(.*?)x(.*?)$/', $req_size, $matches); // fit-100x100
		$thumb_width = $matches[1];
		$thumb_height = $matches[2];
		$thumb_quality = 85;
		break;

	default:
		$size_name = 'fit-80x80';
		$thumb_width = 80;
		$thumb_height = 80;
		$thumb_quality = 75;
}

9 Aug 16, 2008 20:35

Silly answer: that's what I ended up doing.

    case 'fit-160x1600';
        $size_name = 'fit-160x1600';
        $thumb_width = 160;
        $thumb_height = 1600;
        $thumb_quality = 80;

And since I'm hacking away for photoblogginess stuff I changed all the other cases to be "fit-Nx10X' except the 80 by 80 size. Not sure why I left that one out though. Something about ... uh ... oh yeah: I didn't want to hack too much :roll:

EDIT: using the "custom--------" method it just occurred to me lets you make skins on the fly with an image fit parameter that will work for that skin ... down to the pixel if you want.


Form is loading...