Different size thumbnails denending on portrait or landscape
Permalink Browser Info Environment
Hi!
Loving the simplicity of this lightbox. Just wondered if you could help me on this little edit? I'm trying to make the thumbnails be different sizes depending on whether they are landscape or portrait. All photos will be 4:3 ratio. The landscape thumbnails need to be full column width (790px) and the portrait ones need to be floated two side by side (390px with 10px gap between). I am trying to edit the view.php block file to check the aspect ratio of the image and then adjust the thumbnail width but I keep getting a
error.
Any help much appreciated.
Cheers,
Matthew
Loving the simplicity of this lightbox. Just wondered if you could help me on this little edit? I'm trying to make the thumbnails be different sizes depending on whether they are landscape or portrait. All photos will be 4:3 ratio. The landscape thumbnails need to be full column width (790px) and the portrait ones need to be floated two side by side (390px with 10px gap between). I am trying to edit the view.php block file to check the aspect ratio of the image and then adjust the thumbnail width but I keep getting a
getimagesize() expects parameter 1 to be string, object given
<?php if ($images) { foreach ($images as $img): list($originalWidth, $originalHeight) = getimagesize($img); $ratio = $originalWidth / $originalHeight; if ($ratio<1) { $imagewidth = "300px"; } else { $imagewidth = "700px"; } ?> <a style="width:<?php echo $imagewidth;?>" href="<?php echo $img->large->src ?>" style="background-image:url(<?php echo $img->thumb->src ?>);" title="<?php echo $img->title ?>"<?php if ($img->description && $showDesc) { echo ' data-tg-desc="' . $img->description . '"';} ?>></a> <?php endforeach; } ?>
Any help much appreciated.
Cheers,
Matthew
Type: | Discussion |
---|---|
Status: | Resolved |
All the information is actually included in the $image object.
The object has 3 sub-objects if you want: the original image, the resized fullscreen image and the thumbnail.
So to know width and height of the original image you can just do:
I hope it helps