Get Image thumnail

Hi All,

If the 1st file attached to an item is not an image, for example a pdf file, and 2nd or 3rd file attached is an image, how can I get the thumbnail for that image (1st image)?

<?php if (metadata('item', 'has thumnail')): ?>
<div class="item-img">
   <?php echo link_to_item(item_image('square_thumbnail')); ?> 
<?php endif; ?>

The code above will display empty thumbnail if the 1st file attached to the item is not an image. But it could have image(s) attached to it only not the 1st file.

If that is the case, I would like to grab the thumbnail for the first image attached to an item.

Thanks for the helps.



To change the thumbnail used to represent an item on the site, reorder the files for that item. Edit the item and go to the files tab. Drag and drop the attached files so that the one with the thumbnail you want to represent the item is first (on top). Save changes.

Great…thank you so much :wink: