m.donicova's avatar

Photo gallery thumbnails for images with various dimension

I create the simple photo gallery with Laravel and Intervention image. Each photo I resize to width 640 px and then upload to server. For web I am using Bootstrap 3. I have problem. But some photo have landscape and other portrait orientation a this produce problem with grid in html http://trhy.muvalmez.cz/foto. Please how I solve this problem.

0 likes
1 reply
Yorki's avatar

You have to generate fixed size thumbnails to use on grid which then on click displays the original image.

Feel free to use my custom class https://github.com/Yorkii/simple-image

$image = new SimpleImage();

if (!$image->load('my-image.jpg')) {
    return;
}

//This method will automatically determine whenever image should be cropped to mantain aspect ratio
$image->resizeTo(640, 450);
$image->save('my-image-thumb.jpg');

Please or to participate in this conversation.