Hi Ryk,
Thanks for the pointers. To keep things simple then, I have implemented a separate image popup for attribute images - which is probably more sensible than swapping the main product image.
I have used a free, third-party script to generate smoother attribute images on demand rather than trying to hack into IH2. I am however running this alongside IH2 (which naturally brings other benefits) without any problems.
Perhaps I need to package this up as a new contribution when it's tidied up?
To make this work you'll need this script in your root directory:
http://www.zubrag.com/scripts/thumbnail-generator.php
You then need to modify the bottom of file /includes/functions/html_output.php as follows:
// alt is added to the img tag even if it is null to prevent browsers from outputting
// the image filename as default
$image = '<img src="' . zen_output_string($src) . '" alt="' . zen_output_string($alt) . '"';
if (zen_not_null($alt)) {
$image .= ' title=" ' . zen_output_string($alt) . ' "';
}
if (zen_not_null($parameters)) $image .= ' ' . $parameters;
$image .= ' />';
return $image;
}
?>
...becomes...
// alt is added to the img tag even if it is null to prevent browsers from outputting
// the image filename as default
$image = '<img src="thumb.php?src=' . zen_output_string($src) . '&x=100&y=100&f=0" alt="' . zen_output_string($alt) . '"';
if (zen_not_null($alt)) {
$image .= ' title=" ' . zen_output_string($alt) . ' "';
}
if (zen_not_null($parameters)) $image .= ' ' . $parameters;
$image .= ' onclick="popupWindow(\'http://YOURDOMAIN/index.php?main_page=popup_image&src='.zen_output_string($src).'\')"';
$image .= ' />';
return $image;
}
?>
Finally you need to modify the template which displays in the popup image window so that you can present any image you choose simply by providing the path in a new 'src' attribute:
/includes/templates/YOUR_TEMPLATES/popup_image/tpl_main_page.php
Change...
<?php
// $products_values->fields['products_image']
echo '<a href="javascript:window.close()">' . zen_image($products_image_large, $products_values->fields['products_name'] . ' ' . TEXT_CLOSE_WINDOW) . '</a>';
?>
</div>
...to...
<?php
if ($_GET['src']) {
echo '<a href="javascript:window.close()"><img src="' . $_GET['src'] . '"></a>';
} else {
// $products_values->fields['products_image']
echo '<a href="javascript:window.close()">' . zen_image($products_image_large, $products_values->fields['products_name'] . ' ' . TEXT_CLOSE_WINDOW) . '</a>';
}
?>
</div>
This should now present any image you upload in the attributes controller as a server-side scaled image in your products pages and allow you to pop up the full size version in the standard popup image window.
Feel free to test and advise.
ColinR
Bookmarks