creating cropped thumbnails in gallery

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:

$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



View Replies:
JohntheFish replied on at Permalink Reply
You are missing a parameter, so the $crop value is out of place.
$im->outputThumbnail($obj, $maxWidth, $maxHeight, $alt = null, $return = false, $crop = false)

Get rid of the line $img = $html->image($img['thumb_src']); and then generate the thumbnail with:
$thumb = $ih->outputThumbnail($img, 140, 110,'', true, $crop);
JohntheFish replied on at Permalink Reply
rc255 replied on at Permalink Reply
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:
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'])); ?>
      <?php  else: ?>

Perhaps it can't be changed to accomodate that feature, which would be a shame!
JohntheFish replied on at Permalink Reply
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.