I’m wondering if it’s possible to crop and image height only but keep the original width?
i need all images to be the exact same height but different widths even if the user uploads multiple sized images.
Cheers
I’m wondering if it’s possible to crop and image height only but keep the original width?
i need all images to be the exact same height but different widths even if the user uploads multiple sized images.
Cheers
Sure!
// Same width but static height of 123 px
$image->crop($image->width(), 123);
Maybe you can even replace $image->width()
with null
and it will be detected automatically, I haven’t tested that.
don´t work in my code.
<?php echo $page->image($page->coverImage())->crop(width(), 100)->url() ?>
Do you know a solution?
That won’t work, because you have to call the width()
method on an object, not “naked”.
<?php
$image = $page->image($page->coverImage());
echo $image->crop($image->width(), 100)->url() ?>
oh it works! Thank you for fast support!