Latest Register Log In

+ Advanced Search

Landscape and Portrait Thumbnails

Landscape and Portrait Thumbnails
By
11/15/16

Sometimes you may wish to change the dimensions of a thumbnail depending on whether the image is in a landscape or portrait aspect ratio. The {ATTACHTHUMBORIENTATION} / {LINKTHUMBORIENTATION} template variables allow you do make a conditional to do that, like this:

<IF {ATTACHTHUMBORIENTATION} is portrait>{ATTACHTHUMBIMAGE[100 <,> 135]}<ELSE>{ATTACHTHUMBIMAGE[180 <,> 135]}</IF>

You can also use {LINK variables to check the Xth file of the listing (file #1 in this example): <IF {LINKTHUMBORIENTATION[1]} is portrait>{LINKTHUMBIMAGEX[1 <,> 100 <,> 135]}<ELSE>{LINKTHUMBIMAGEX[1 <,> 180 <,> 135]}</IF>

One particular use case is when you want a row of thumbnails that all have exactly the same height but can vary between two widths depending whether they're landscape or portrait. There's a special parameter you can use on {LINKIMAGE} or {ATTACHIMAGE} to force it to stretch to a specific size instead of keeping the original aspect ratio. If you want your row of images to be all exactly 135px tall, and to be 100px wide when portrait or 180px wide when landscape, you can do this:

<IF {ATTACHTHUMBORIENTATION} is portrait>{ATTACHTHUMBIMAGE[100 <,> 135 <,> 0 <,> 0 <,> 0 <,> 0 <,> 0 <,> true]}<ELSE>{ATTACHTHUMBIMAGE[180 <,> 135 <,> 0 <,> 0 <,> 0 <,> 0 <,> 0 <,> true]}</IF>

Or for the first images of listings:

<IF {LINKTHUMBORIENTATION} is portrait>{LINKTHUMBIMAGE[100 <,> 135 <,> 1 <,> 0 <,> 0 <,> 0 <,> 0 <,> true]}<ELSE>{LINKTHUMBIMAGE[180 <,> 135 <,> 1 <,> 0 <,> 0 <,> 0 <,> 0 <,> true]}</IF>




Rating
Views 237 views. Averaging 0 views per day.