Resize question

See all posts Reply

Resize question new!
by Pol, 9 years, 7 months ago
Hello,
I'm facing a tricky situation and I don't know if upload.cass.php can handle it.
I'm building an administration panel for a portfolio website, and I need the uploaded images to be resized to fit into the sliders displayed on the frontend.
I have a fixed slider width (1120px), but I would like to have a variable height (which maximum would be 800px)... I need all the images to be resized to fill this width (using image_ratio_fill for the portrait orientation ones).
If I use image_ratio, image_ratio_fill, image_x and image_y, all my images are resized, based on image_x and image_y values (which is the expected behavior). But I would like my landscape oriented images no to use image_ratio_fill and to have a "fluid" image_y value.
So far, I haven't been able to achieve that (if I use image_ratio_y, the landscape images are resized as I want them to be, but the portrait ones are also resized to the same width, which is far too big).
In brief, I'm looking for a way to emulate a sort of "image_ratio_fill_y" to only fill if my images width is smaller than 1120px.
I hope I made myself clear, please tell me if I haven't.
Thanks in advance and best regards,
PolReply
Re: Resize question new!
by Pol, 9 years, 7 months ago
I think I found a solution. I'm sharing it here in case someone is facing the same problem:

$handle->image_ratio          = true;
if($handle->image_src_x < $handle->image_src_y) {
  $handle->image_ratio_y      = false;
  $handle->image_ratio_fill   = true;
} else {
  $handle->image_ratio_y      = true;
  $handle->image_ratio_fill   = false;
}

Best regards,
PolReply