Jump to content

Recommended Posts

Posted

Is it possible to get an image scaled down proportionally, like for example, I need it to fit in a 400px box (no height constraint). And the images might have different heights that would respond to the given constraint? Right now it seems I need to specify the width and height of the image that it placed, but the problem is I have images of different sizes and proportions.

Posted

You can specify 0 for the width or height to have it be proportional to the other dimension. Or you can just use the width(x) or height(y) functions rather than size(x, y) function. So in your case, I think what you are asking for is this:

$image = $page->image->width(400); 
Posted

With this method, any smaller image will be also resized, right? Is there any API way of doing something that only resizes bigger images?

Posted

There might be better way to do it, but this should work:

if ($image->width > 32 || $image->height > 32) $img = $image->size(32,32);
else $img = $image;
Posted

Thanks Apeisa, I used it like this

if($image->width > 500) $image = $image->width(500); ?>
<img src="<?php echo $image->url?>" alt="">

but would be very nice to have a maxwidth() in PW

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...