Development Manager @ JSWeb Ltd - suppliers of Applepay/Googlepay for Zencart
20 years with Zencart !
Hi Ryk,
Further to my previous post I think I have got to the bottom of this.
When I first looked at this a couple of weeks back I duplicated the html image wrapper function 'zen_attribute_image' in /includes/functions/html_output.php and renamed the duplicate function 'zen_attribute_image' so that I could easily apply new code to attribute images only.
Here then is the complete zen_attribute_image function - including the pop-up code modifications I sent last night - which should simply be appended to /includes/functions/html_output.php.
/*
* The HTML attribute image wrapper function
*/
function zen_attribute_image($src, $alt = '', $width = '', $height = '', $parameters = '') {
global $template_dir;
// soft clean the alt tag
$alt = zen_clean_html($alt);
// use old method on template images
if (strstr($src, 'includes/templates') or strstr($src, 'includes/languages') or PROPORTIONAL_IMAGES_STATUS == '0') {
return zen_image_OLD($src, $alt, $width, $height, $parameters);
}
//auto replace with defined missing image
if ($src == DIR_WS_IMAGES and PRODUCTS_IMAGE_NO_IMAGE_STATUS == '1') {
$src = DIR_WS_IMAGES . PRODUCTS_IMAGE_NO_IMAGE;
}
if ( (empty($src) || ($src == DIR_WS_IMAGES)) && (IMAGE_REQUIRED == 'false') ) {
return false;
}
// if not in current template switch to template_default
if (!file_exists($src)) {
$src = str_replace(DIR_WS_TEMPLATES . $template_dir, DIR_WS_TEMPLATES . 'template_default', $src);
}
// hook for handle_image() function such as Image Handler etc
if (function_exists('handle_image')) {
$newimg = handle_image($src, $alt, $width, $height, $parameters);
list($src, $alt, $width, $height, $parameters) = $newimg;
}
// Convert width/height to int for proper validation.
// intval() used to support compatibility with plugins like image-handler
$width = empty($width) ? $width : intval($width);
$height = empty($height) ? $height : intval($height);
// 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=41&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://YOUR_DOMAIN/index.php?main_page=popup_image&src='.zen_output_string($src).'\')"';
$image .= ' />';
return $image;
}
?>
You then need to modify /includes/modules/attributes.php (or naturally a copy of this file at /includes/modules/YOUR_TEMPLATES/attributes.php) changing all occurances of...
zen_image(
...to..
zen_attribute_image(
...so that the new zen_attribute_image function is called rather than the generic zen_image function.
There may, of course, be a more elegant way to do this. Any suggestions are welcome.
ColinR
BRILLIANT!!
![]()
Thank you - that's superb.
One possibility for improvement that you may be able to rattle off the top of your head, but which would take me hours of trial and error
Could it be made obvious that the attribute image is now a link? The mouse pointer doesn't change when rolled over.
Last edited by Ryk; 16 Nov 2006 at 12:24 AM.
Development Manager @ JSWeb Ltd - suppliers of Applepay/Googlepay for Zencart
20 years with Zencart !
Cheers!![]()
/includes/templates/YOUR_TEMPLATES/css/stylesheet.css
attribImg { cursor: pointer; cursor: hand; }
...or...
attribImg img { cursor: pointer; cursor: hand; }
...ought to do it.
Alternatively:
$image = '<a href="javascript: popupWindow(\'http://YOUR_DOMAIN/index.php?main_page=popup_image&src='.zen_output_s tring($src).'\')"><img src="thumb.php?src=' . zen_output_string($src) . '&x=100&y=41&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 .= ' /></a>';
ColinR
Last edited by colinr; 16 Nov 2006 at 12:51 AM.
Last edited by Ryk; 16 Nov 2006 at 01:17 AM.
Development Manager @ JSWeb Ltd - suppliers of Applepay/Googlepay for Zencart
20 years with Zencart !
Because I had some problems with the zoom in, I tried to reinstall Image Handler, but now I get this error on my front-page:
Fatal error: imagepng() [<a href='function.imagepng'>function.imagepng</a>]: gd-png: fatal libpng error: zlib error in /opt/lampp/htdocs/zencartnieuw/includes/classes/bmz_image_handler.class.php on line 646
It's under the welcome message, the rest of the front page is normal.
Does anybody have a clue what this could be?
Oh yeah, I'm using the newest version of xampp (for a while now). I had Image Handler working the first time on the same test-server.
Hi Ryk,
If you're happy to lend a hand turning this into a downloadable contribution that would be great as I'm a bit short of time at the moment.
I've sent a message to the developer of the thumb.php script to see if I can include it in the package and will let you know. If not then a link in the installation instructions would do it - but naturally this could break at some point.
As this stuff is actually independent of IH2 we could extend it's use to improve the presentation of ALL images from an otherwise default ZenCart install.
It may also be possible to modify the core zen_image function(s) rather than creating a new zen_attribute_image function - but we'll need to look into this.
Ok. I'm not sure if this would work for all browsers so to play it safe we can replace http://YOUR_DOMAIN/ with the base href variable. Should be easy enough.
ColinR
Check your PMs.
Re the domain ... only checked on FF & IE, but vaild point.
Development Manager @ JSWeb Ltd - suppliers of Applepay/Googlepay for Zencart
20 years with Zencart !
Okay, it seems to work well except:
When rollover/popups are enabled, all my original 2nd, 3rd etc images are gone on the product page. No big deal, I didn't need this feature anyway.
HOWEVER:
When uploading an image for a product, I MUST select a "base name" (which says "optional") for it to upload all three sizes (otherwise they're all the same LARGE size). Subsequent uploads for the same product - additional images - do not require that I add the base name.
Is this how it's supposed to work? The "optional" tag makes me thing this is off just a bit.
Chris
Bookmarks