Attribute images with Image Handler 2
Hi There,
I have successfully installed IH2 and my sites looks much better for it in IE6 which doesn't handle client-side scaling at all well.
There are however a couple of things which I need to get working and any help/pointers would be great:
1) Attribute images are still poor quality, client-side scalings not handled by IH2. Is this a problem with my install? Or has support for this not been developed?
If the case is the latter, then is there an easy way for me to call images using IH2 so that can have a go at making the changes myself? Or can anyone on the list recommend an alternative solution?
2) I would also like to add some javascript to change the main product image each time an attribute option is selected or an attribute image is clicked.
Does anyone on the list have a script which can do this?
Thanks in advance
ColinR
Re: Image Handler 2 Support
IH2 handles ONLY product images.
There is a Swap Image on MouseOver mod by DrByte somewhere, but it isn't (as far as I know) compatible with IH2. However, it may give you some pointers ...and if you can come up with a working version with IH2 installed, that would be an extremely useful contribution to add to the community.
However, image swapping doesn't have to be javascript... take a look at http://www.cssplay.co.uk/menu/gallery.html (oh sorry - there goes the next couple of hours! :D ) where there's some great ideas. (How it's done is nearly always in his View Source)
Re: Image Handler 2 Support
*bookmarks link :)
lot's of good stuff in there. :)
Re: Image Handler 2 Support
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
Re: Image Handler 2 Support
We have IH version 2.0 installed on a zencart version 1.3.6 - is there a sql patch required? The additional images are not showing on the category pages. I checked under admin/product types to edit those configs (to show additional images) and that's not even an option. I checked the sql tables, and the option isn't listed. I've searched other threads and can't seem to find an answer. If there is a sql patch required, where could I find it?
Thanks,
Danielle
Re: Image Handler 2 Support
@colinr - thanks; I'll give that a try later (hopefully!)
@chayton6 - did you install the latest version of IH2 from the download section AFTER 1.3.6? You do need to do it that way...there is a post by DrByte somewhere explaining about ereg replacement.
Re: Image Handler 2 Support
colinr - what version of ZC are you using? Your html_output doesn't match the 1.3.6 one...and there are two sections at about line 120 and about line 196 with similar code to above...neither of which is anywhere near the end of the file! :D
However, the second instance does have some effect, but not what I was hoping for! The main product image has disappeared and the attribute images now appear to be expanded thumbnails!!
OK, I'm going to start this again. :D
Re: Image Handler 2 Support
Nope - can't get this to work; is it working for you colinr? Have carefully re-done the procedure you've outlined and the results are the same as I reported earlier.
Re: Image Handler 2 Support
@chayton6 - did you install the latest version of IH2 from the download section AFTER 1.3.6? You do need to do it that way...there is a post by DrByte somewhere explaining about ereg replacement.[/QUOTE]
Yes, I read his posts. No, I did not install IH2 after the cart. Actually, I didn't do the installs at all. The store owner had the cart upgraded from a prev version to 1.3.6. I read the threads and he'd listed three pages that need to be used from the IH2 install (additional_images.php I believe and 2 others) and I uploaded those from the IH2 install. But that's not really addressing the fact that I don't have the option to set 'show additional images' to true - that option doesn't exist on my products types / edit layout page and isn't in my sql tables as an option. That's why I asked about the sql patch.
Re: Image Handler 2 Support
Quote:
Originally Posted by
Ryk
Nope - can't get this to work; is it working for you colinr? Have carefully re-done the procedure you've outlined and the results are the same as I reported earlier.
Sorry about that. It definately works - but I think the 'original' code I sent through was actually a mod I had done previously and overlooked. Too many late nights. :blink:
I will check through my code when I get a chance and send amendments.
ColinR