creating cropped thumbnails in gallery
Permalink
I'm trying to get thumbnails in a gallery to all conform to the same size using the imageHelper, but I can't see where I'm going wrong:
Can anyone give me any pointers as this is becoming really frustrating... If I change the code to:
it outputs the correct thumbnail but not cropped to size, but I really want all the thumbnails to be cropped and to the same size and orientation...
Please help
Regards
Rob
<?php $ih = Loader::helper('image'); foreach ($images as $img): $crop = true; $img = $html->image($img['thumb_src']); $thumb = $ih->outputThumbnail($img, 140, 110,'', $crop); echo $thumb; ?>
Can anyone give me any pointers as this is becoming really frustrating... If I change the code to:
echo $img;
it outputs the correct thumbnail but not cropped to size, but I really want all the thumbnails to be cropped and to the same size and orientation...
Please help
Regards
Rob
Have a look at the addons List Files From Set and Image List templates
http://www.concrete5.org/marketplace/addons/list-files-from-set/...
http://www.concrete5.org/marketplace/addons/image-list-templates/...
http://www.concrete5.org/marketplace/addons/list-files-from-set/...
http://www.concrete5.org/marketplace/addons/image-list-templates/...
I must be missing something... I'm actually trying to customise the 'Sortable Fancybox Gallery'... This is the original code which just outputs the thumnail as 'smaller' versions of the full image and not as a cropped image as desired:
Perhaps it can't be changed to accomodate that feature, which would be a shame!
<?php defined('C5_EXECUTE') or die(_("Access Denied.")); $html = Loader::helper('html'); $column_width = (100 / $displayColumns) . "%"; $rel = "fancybox{$controller->bID}"; //Avoid conflict with other js lightboxes, and isolate each block's prev/next nav to one gallery only. $c = Page::getCurrentPage(); ?> <div class="sortable_fancybox_gallery_container"> <?php foreach ($images as $img): ?> <div class="sortable_fancybox_gallery_image" style="height: <?php echo $max_row_height; ?>px; width: <?php echo $column_width; ?>;"> <?php if ($enableLightbox): ?> <a href="<?php echo $img['full_src']; ?>" rel="<?php echo $rel; ?>" title="<?php echo $img['description']; ?>"> <?php echo $html->image($img['thumb_src'], $img['thumb_width'], $img['thumb_height'], array('alt' => $img['title'])); ?> </a> <?php else: ?>
Viewing 15 lines of 60 lines. View entire code block.
Perhaps it can't be changed to accomodate that feature, which would be a shame!
The image helper outputThumbnail() requires a file object as the first parameter. What you were giving it was a file path.
The c5 files system maintains some standard size thumbnails. I think the sortable fancybox code was using one of those and simply applying html image attributes to scale rather than generating an exact thumbnail.
Bear in mind that unless the large image has exactly the same aspect ratio as the desired thumbnail size, you will either have a thumbnail undersized in one dimension, or it will need to be cropped in the other dimension.
The c5 files system maintains some standard size thumbnails. I think the sortable fancybox code was using one of those and simply applying html image attributes to scale rather than generating an exact thumbnail.
Bear in mind that unless the large image has exactly the same aspect ratio as the desired thumbnail size, you will either have a thumbnail undersized in one dimension, or it will need to be cropped in the other dimension.
http://www.concrete5.org/documentation/developers/files/helpers/...
Get rid of the line $img = $html->image($img['thumb_src']); and then generate the thumbnail with: