Different size thumbnails denending on portrait or landscape

Permalink Browser Info Environment

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.


Type: Discussion
Status: Resolved
View Replies:
mnakalay replied on at Permalink Reply

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:
$originalWidth = $image->orig->width; 
$originalHeight = $image->orig->height;

I hope it helps
maffp replied on at Permalink Reply
Bang on! Got it working just how I want it now! Cheers!

concrete5 Environment Information

# concrete5 Version
Core Version -
Version Installed -
Database Version - 20150109000000

# concrete5 Packages
Block Designer (1.0.2), Equinox (1.0.0), Touch Gallery (2.0.4).

# concrete5 Overrides
blocks/gdlightbox, blocks/gdvimage, languages/da_DK, languages/de_DE, languages/el_GR, languages/fi_FI, languages/fr_FR, languages/it_IT, languages/ja_JP, languages/nl_NL, languages/ru_RU, languages/sl_SI, languages/sv_SE, languages/tr_TR

# concrete5 Cache Settings
Block Cache - Off
Overrides Cache - Off
Full Page Caching - Off
Full Page Cache Lifetime - Every 6 hours (default setting).

# Server Software
Apache/2.4.9 (Win64) PHP/5.5.12

# Server API

# PHP Version

# PHP Extensions
apache2handler, bcmath, bz2, calendar, com_dotnet, Core, ctype, curl, date, dom, ereg, exif, fileinfo, filter, ftp, gd, gettext, gmp, hash, iconv, imap, json, libxml, mbstring, mcrypt, mhash, mysql, mysqli, mysqlnd, odbc, openssl, pcre, PDO, pdo_mysql, pdo_sqlite, Phar, Reflection, session, shmop, SimpleXML, soap, sockets, SPL, sqlite3, standard, tokenizer, wddx, xdebug, xml, xmlreader, xmlrpc, xmlwriter, xsl, zip, zlib.

# PHP Settings
max_execution_time - 120
log_errors_max_len - 1024
max_file_uploads - 20
max_input_nesting_level - 64
max_input_time - 60
max_input_vars - 2500
memory_limit - 128M
post_max_size - 3M
sql.safe_mode - Off
upload_max_filesize - 64M
mysql.max_links - Unlimited
mysql.max_persistent - Unlimited
mysqli.max_links - Unlimited
mysqli.max_persistent - Unlimited
odbc.max_links - Unlimited
odbc.max_persistent - Unlimited
pcre.backtrack_limit - 1000000
pcre.recursion_limit - 100000
session.cache_limiter - <i>no value</i>
session.gc_maxlifetime - 1800
soap.wsdl_cache_limit - 5
xdebug.max_nesting_level - 2000
xdebug.var_display_max_children - 128
xdebug.var_display_max_data - 512
xdebug.var_display_max_depth - 3

Browser User-Agent String

Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You may not request a refund that is not currently owned by you.