Re: Hover image alignment
That was not enough either. I have had to change each notifier. Hence, replace whole of \includes\classes\observers\ImageHandlerObserver.php
with
Code:
<?php
// -----
// Part of the "Image Handler" plugin for Zen Cart 1.5.5b and later.
// Copyright (c) 2017-2021 Vinos de Frutas Tropicales
//
if (!defined('IS_ADMIN_FLAG')) {
die('Illegal Access');
}
class ImageHandlerObserver extends base
{
public function __construct()
{
if (defined('IH_RESIZE') && IH_RESIZE == 'yes') {
$this->attach(
$this,
[
//- From /includes/modules/main_product_image.php
'NOTIFY_MODULES_MAIN_PRODUCT_IMAGE_FILENAME',
//- From /includes/modules/additional_images.php
'NOTIFY_MODULES_ADDITIONAL_IMAGES_GET_LARGE',
'NOTIFY_MODULES_ADDITIONAL_IMAGES_THUMB_SLASHES',
//- From /includes/pages/popup_image/header_php.php
'NOTIFY_HEADER_END_POPUP_IMAGES',
]
);
}
}
public function update(&$class, $eventID, $p1, &$p2, &$p3, &$p4, &$p5, &$p6)
{
switch ($eventID) {
// -----
// This notifier lets an image-handling observer know that it's time to determine the image information,
// providing the following parameters:
//
// $p1 ... (r/o) ... A copy of the $products_image value
// $p2 ... (r/w) ... A boolean value, set by the observer to true if the image has been handled.
// $p3 ... (r/w) ... A reference to the $products_image_extension value
// $p4 ... (r/w) ... A reference to the $products_image_base value
// $p5 ... (r/w) ... A reference to the medium product-image-name
// $p6 ... (r/w) ... A reference to the large product-image-name.
//
// If the observer has set the $product_image_handled flag to true, it's indicated that any of the
// other values have been updated for separate handling.
//
case 'NOTIFY_MODULES_MAIN_PRODUCT_IMAGE_FILENAME':
if (strtolower($p3) == '.webp') {
break;
}
$products_image = $p1;
$products_image_extension = $p3;
$p4 = $products_image_base = preg_replace('/' . $products_image_extension . '$/', '', $products_image);
$p5 = DIR_WS_IMAGES . 'medium/' . $products_image_base . IMAGE_SUFFIX_MEDIUM . $products_image_extension;
$p6 = DIR_WS_IMAGES . 'large/' . $products_image_base . IMAGE_SUFFIX_LARGE . $products_image_extension;
$p2 = true; //-Indicate that the image has been "handled".
break;
// -----
// This notifier lets any image-handler know the current image being processed, providing the following parameters:
//
// $p1 ... (r/o) ... The current product's name
// $p2 ... (r/w) ... The (possibly updated) filename (including path) of the current additional image.
//
case 'NOTIFY_MODULES_ADDITIONAL_IMAGES_GET_LARGE':
if (strtolower(substr($p2,-5)) == '.webp') {
break;
}
$products_name = $p1;
$products_image_large = $p2;
if (function_exists('handle_image')) {
$newimg = handle_image($products_image_large, addslashes($products_name), LARGE_IMAGE_MAX_WIDTH, LARGE_IMAGE_MAX_HEIGHT, '');
list($src, $alt, $width, $height, $parameters) = $newimg;
$p2 = zen_output_string($src);
}
break;
// -----
// This notifier lets any image-handler "massage" the name of the current thumbnail image name with appropriate
// slashes for javascript/jQuery display:
//
// $p1 ... (n/a) ... An empty array, not applicable.
// $p2 ... (r/w) ... A reference to the "slashed" thumbnail image name.
//
case 'NOTIFY_MODULES_ADDITIONAL_IMAGES_THUMB_SLASHES':
// remove additional single quotes from image attributes (important!)
if (strtolower(substr($p2,-5)) == '.webp') {
break;
}
$thumb_slashes = $p2;
$p2 = preg_replace("/([^\\\\])'/", '$1\\\'', $thumb_slashes);
break;
// -----
// Update the (globally-available) image names for any rendering of the popup_image page.
//
case 'NOTIFY_HEADER_END_POPUP_IMAGES':
global $products_image,
$products_image_extension,
$products_image_base,
$products_image_medium,
$products_image_large;
if (srttolower($products_image_extension) == '.webp'){
break;
}
$products_image_base = preg_replace('/' . $products_image_extension . '$/', '', $products_image);
$products_image_medium = DIR_WS_IMAGES . 'medium/' . $products_image_base . IMAGE_SUFFIX_MEDIUM . $products_image_extension;
$products_image_large = DIR_WS_IMAGES . 'large/' . $products_image_base . IMAGE_SUFFIX_LARGE . $products_image_extension;
break;
default:
break;
}
}
}
Re: Hover image alignment
Thank you lat9. Really appreciate all the hard work.
Re: Hover image alignment
Quote:
Originally Posted by
brittainmark
That was not enough either. I have had to change each notifier. Hence, replace whole of \includes\classes\observers\ImageHandlerObserver.php
with
Code:
<?php
// -----
// Part of the "Image Handler" plugin for Zen Cart 1.5.5b and later.
// Copyright (c) 2017-2021 Vinos de Frutas Tropicales
//
if (!defined('IS_ADMIN_FLAG')) {
die('Illegal Access');
}
class ImageHandlerObserver extends base
{
public function __construct()
{
if (defined('IH_RESIZE') && IH_RESIZE == 'yes') {
$this->attach(
$this,
[
//- From /includes/modules/main_product_image.php
'NOTIFY_MODULES_MAIN_PRODUCT_IMAGE_FILENAME',
//- From /includes/modules/additional_images.php
'NOTIFY_MODULES_ADDITIONAL_IMAGES_GET_LARGE',
'NOTIFY_MODULES_ADDITIONAL_IMAGES_THUMB_SLASHES',
//- From /includes/pages/popup_image/header_php.php
'NOTIFY_HEADER_END_POPUP_IMAGES',
]
);
}
}
public function update(&$class, $eventID, $p1, &$p2, &$p3, &$p4, &$p5, &$p6)
{
switch ($eventID) {
// -----
// This notifier lets an image-handling observer know that it's time to determine the image information,
// providing the following parameters:
//
// $p1 ... (r/o) ... A copy of the $products_image value
// $p2 ... (r/w) ... A boolean value, set by the observer to true if the image has been handled.
// $p3 ... (r/w) ... A reference to the $products_image_extension value
// $p4 ... (r/w) ... A reference to the $products_image_base value
// $p5 ... (r/w) ... A reference to the medium product-image-name
// $p6 ... (r/w) ... A reference to the large product-image-name.
//
// If the observer has set the $product_image_handled flag to true, it's indicated that any of the
// other values have been updated for separate handling.
//
case 'NOTIFY_MODULES_MAIN_PRODUCT_IMAGE_FILENAME':
if (strtolower($p3) == '.webp') {
break;
}
$products_image = $p1;
$products_image_extension = $p3;
$p4 = $products_image_base = preg_replace('/' . $products_image_extension . '$/', '', $products_image);
$p5 = DIR_WS_IMAGES . 'medium/' . $products_image_base . IMAGE_SUFFIX_MEDIUM . $products_image_extension;
$p6 = DIR_WS_IMAGES . 'large/' . $products_image_base . IMAGE_SUFFIX_LARGE . $products_image_extension;
$p2 = true; //-Indicate that the image has been "handled".
break;
// -----
// This notifier lets any image-handler know the current image being processed, providing the following parameters:
//
// $p1 ... (r/o) ... The current product's name
// $p2 ... (r/w) ... The (possibly updated) filename (including path) of the current additional image.
//
case 'NOTIFY_MODULES_ADDITIONAL_IMAGES_GET_LARGE':
if (strtolower(substr($p2,-5)) == '.webp') {
break;
}
$products_name = $p1;
$products_image_large = $p2;
if (function_exists('handle_image')) {
$newimg = handle_image($products_image_large, addslashes($products_name), LARGE_IMAGE_MAX_WIDTH, LARGE_IMAGE_MAX_HEIGHT, '');
list($src, $alt, $width, $height, $parameters) = $newimg;
$p2 = zen_output_string($src);
}
break;
// -----
// This notifier lets any image-handler "massage" the name of the current thumbnail image name with appropriate
// slashes for javascript/jQuery display:
//
// $p1 ... (n/a) ... An empty array, not applicable.
// $p2 ... (r/w) ... A reference to the "slashed" thumbnail image name.
//
case 'NOTIFY_MODULES_ADDITIONAL_IMAGES_THUMB_SLASHES':
// remove additional single quotes from image attributes (important!)
if (strtolower(substr($p2,-5)) == '.webp') {
break;
}
$thumb_slashes = $p2;
$p2 = preg_replace("/([^\\\\])'/", '$1\\\'', $thumb_slashes);
break;
// -----
// Update the (globally-available) image names for any rendering of the popup_image page.
//
case 'NOTIFY_HEADER_END_POPUP_IMAGES':
global $products_image,
$products_image_extension,
$products_image_base,
$products_image_medium,
$products_image_large;
if (srttolower($products_image_extension) == '.webp'){
break;
}
$products_image_base = preg_replace('/' . $products_image_extension . '$/', '', $products_image);
$products_image_medium = DIR_WS_IMAGES . 'medium/' . $products_image_base . IMAGE_SUFFIX_MEDIUM . $products_image_extension;
$products_image_large = DIR_WS_IMAGES . 'large/' . $products_image_base . IMAGE_SUFFIX_LARGE . $products_image_extension;
break;
default:
break;
}
}
}
Thank you brittainmark . I will try your fix and report back.
Re: Hover image alignment
Quote:
Originally Posted by
brittainmark
That was not enough either. I have had to change each notifier. Hence, replace whole of \includes\classes\observers\ImageHandlerObserver.php
with
Code:
<?php
// -----
// Part of the "Image Handler" plugin for Zen Cart 1.5.5b and later.
// Copyright (c) 2017-2021 Vinos de Frutas Tropicales
//
if (!defined('IS_ADMIN_FLAG')) {
die('Illegal Access');
}
class ImageHandlerObserver extends base
{
public function __construct()
{
if (defined('IH_RESIZE') && IH_RESIZE == 'yes') {
$this->attach(
$this,
[
//- From /includes/modules/main_product_image.php
'NOTIFY_MODULES_MAIN_PRODUCT_IMAGE_FILENAME',
//- From /includes/modules/additional_images.php
'NOTIFY_MODULES_ADDITIONAL_IMAGES_GET_LARGE',
'NOTIFY_MODULES_ADDITIONAL_IMAGES_THUMB_SLASHES',
//- From /includes/pages/popup_image/header_php.php
'NOTIFY_HEADER_END_POPUP_IMAGES',
]
);
}
}
public function update(&$class, $eventID, $p1, &$p2, &$p3, &$p4, &$p5, &$p6)
{
switch ($eventID) {
// -----
// This notifier lets an image-handling observer know that it's time to determine the image information,
// providing the following parameters:
//
// $p1 ... (r/o) ... A copy of the $products_image value
// $p2 ... (r/w) ... A boolean value, set by the observer to true if the image has been handled.
// $p3 ... (r/w) ... A reference to the $products_image_extension value
// $p4 ... (r/w) ... A reference to the $products_image_base value
// $p5 ... (r/w) ... A reference to the medium product-image-name
// $p6 ... (r/w) ... A reference to the large product-image-name.
//
// If the observer has set the $product_image_handled flag to true, it's indicated that any of the
// other values have been updated for separate handling.
//
case 'NOTIFY_MODULES_MAIN_PRODUCT_IMAGE_FILENAME':
if (strtolower($p3) == '.webp') {
break;
}
$products_image = $p1;
$products_image_extension = $p3;
$p4 = $products_image_base = preg_replace('/' . $products_image_extension . '$/', '', $products_image);
$p5 = DIR_WS_IMAGES . 'medium/' . $products_image_base . IMAGE_SUFFIX_MEDIUM . $products_image_extension;
$p6 = DIR_WS_IMAGES . 'large/' . $products_image_base . IMAGE_SUFFIX_LARGE . $products_image_extension;
$p2 = true; //-Indicate that the image has been "handled".
break;
// -----
// This notifier lets any image-handler know the current image being processed, providing the following parameters:
//
// $p1 ... (r/o) ... The current product's name
// $p2 ... (r/w) ... The (possibly updated) filename (including path) of the current additional image.
//
case 'NOTIFY_MODULES_ADDITIONAL_IMAGES_GET_LARGE':
if (strtolower(substr($p2,-5)) == '.webp') {
break;
}
$products_name = $p1;
$products_image_large = $p2;
if (function_exists('handle_image')) {
$newimg = handle_image($products_image_large, addslashes($products_name), LARGE_IMAGE_MAX_WIDTH, LARGE_IMAGE_MAX_HEIGHT, '');
list($src, $alt, $width, $height, $parameters) = $newimg;
$p2 = zen_output_string($src);
}
break;
// -----
// This notifier lets any image-handler "massage" the name of the current thumbnail image name with appropriate
// slashes for javascript/jQuery display:
//
// $p1 ... (n/a) ... An empty array, not applicable.
// $p2 ... (r/w) ... A reference to the "slashed" thumbnail image name.
//
case 'NOTIFY_MODULES_ADDITIONAL_IMAGES_THUMB_SLASHES':
// remove additional single quotes from image attributes (important!)
if (strtolower(substr($p2,-5)) == '.webp') {
break;
}
$thumb_slashes = $p2;
$p2 = preg_replace("/([^\\\\])'/", '$1\\\'', $thumb_slashes);
break;
// -----
// Update the (globally-available) image names for any rendering of the popup_image page.
//
case 'NOTIFY_HEADER_END_POPUP_IMAGES':
global $products_image,
$products_image_extension,
$products_image_base,
$products_image_medium,
$products_image_large;
if (srttolower($products_image_extension) == '.webp'){
break;
}
$products_image_base = preg_replace('/' . $products_image_extension . '$/', '', $products_image);
$products_image_medium = DIR_WS_IMAGES . 'medium/' . $products_image_base . IMAGE_SUFFIX_MEDIUM . $products_image_extension;
$products_image_large = DIR_WS_IMAGES . 'large/' . $products_image_base . IMAGE_SUFFIX_LARGE . $products_image_extension;
break;
default:
break;
}
}
}
It seems to be working so far asa temporary fix. Thanks again for it as my log files were starting to pile up. :-)
As times goes, it seems that we will have to switch to .webp for all the product images which brings up another question.
If I create a new product with a .webp image, do i need to upload 3 different image size for small, medium and large? (since IH will not be resizing/caching then)
Thank you
Re: Hover image alignment
Quote:
Originally Posted by
brittainmark
That was not enough either. I have had to change each notifier. Hence, replace whole of \includes\classes\observers\ImageHandlerObserver.php
with
Code:
<?php
// -----
// Part of the "Image Handler" plugin for Zen Cart 1.5.5b and later.
// Copyright (c) 2017-2021 Vinos de Frutas Tropicales
//
if (!defined('IS_ADMIN_FLAG')) {
die('Illegal Access');
}
class ImageHandlerObserver extends base
{
public function __construct()
{
if (defined('IH_RESIZE') && IH_RESIZE == 'yes') {
$this->attach(
$this,
[
//- From /includes/modules/main_product_image.php
'NOTIFY_MODULES_MAIN_PRODUCT_IMAGE_FILENAME',
//- From /includes/modules/additional_images.php
'NOTIFY_MODULES_ADDITIONAL_IMAGES_GET_LARGE',
'NOTIFY_MODULES_ADDITIONAL_IMAGES_THUMB_SLASHES',
//- From /includes/pages/popup_image/header_php.php
'NOTIFY_HEADER_END_POPUP_IMAGES',
]
);
}
}
public function update(&$class, $eventID, $p1, &$p2, &$p3, &$p4, &$p5, &$p6)
{
switch ($eventID) {
// -----
// This notifier lets an image-handling observer know that it's time to determine the image information,
// providing the following parameters:
//
// $p1 ... (r/o) ... A copy of the $products_image value
// $p2 ... (r/w) ... A boolean value, set by the observer to true if the image has been handled.
// $p3 ... (r/w) ... A reference to the $products_image_extension value
// $p4 ... (r/w) ... A reference to the $products_image_base value
// $p5 ... (r/w) ... A reference to the medium product-image-name
// $p6 ... (r/w) ... A reference to the large product-image-name.
//
// If the observer has set the $product_image_handled flag to true, it's indicated that any of the
// other values have been updated for separate handling.
//
case 'NOTIFY_MODULES_MAIN_PRODUCT_IMAGE_FILENAME':
if (strtolower($p3) == '.webp') {
break;
}
$products_image = $p1;
$products_image_extension = $p3;
$p4 = $products_image_base = preg_replace('/' . $products_image_extension . '$/', '', $products_image);
$p5 = DIR_WS_IMAGES . 'medium/' . $products_image_base . IMAGE_SUFFIX_MEDIUM . $products_image_extension;
$p6 = DIR_WS_IMAGES . 'large/' . $products_image_base . IMAGE_SUFFIX_LARGE . $products_image_extension;
$p2 = true; //-Indicate that the image has been "handled".
break;
// -----
// This notifier lets any image-handler know the current image being processed, providing the following parameters:
//
// $p1 ... (r/o) ... The current product's name
// $p2 ... (r/w) ... The (possibly updated) filename (including path) of the current additional image.
//
case 'NOTIFY_MODULES_ADDITIONAL_IMAGES_GET_LARGE':
if (strtolower(substr($p2,-5)) == '.webp') {
break;
}
$products_name = $p1;
$products_image_large = $p2;
if (function_exists('handle_image')) {
$newimg = handle_image($products_image_large, addslashes($products_name), LARGE_IMAGE_MAX_WIDTH, LARGE_IMAGE_MAX_HEIGHT, '');
list($src, $alt, $width, $height, $parameters) = $newimg;
$p2 = zen_output_string($src);
}
break;
// -----
// This notifier lets any image-handler "massage" the name of the current thumbnail image name with appropriate
// slashes for javascript/jQuery display:
//
// $p1 ... (n/a) ... An empty array, not applicable.
// $p2 ... (r/w) ... A reference to the "slashed" thumbnail image name.
//
case 'NOTIFY_MODULES_ADDITIONAL_IMAGES_THUMB_SLASHES':
// remove additional single quotes from image attributes (important!)
if (strtolower(substr($p2,-5)) == '.webp') {
break;
}
$thumb_slashes = $p2;
$p2 = preg_replace("/([^\\\\])'/", '$1\\\'', $thumb_slashes);
break;
// -----
// Update the (globally-available) image names for any rendering of the popup_image page.
//
case 'NOTIFY_HEADER_END_POPUP_IMAGES':
global $products_image,
$products_image_extension,
$products_image_base,
$products_image_medium,
$products_image_large;
if (srttolower($products_image_extension) == '.webp'){
break;
}
$products_image_base = preg_replace('/' . $products_image_extension . '$/', '', $products_image);
$products_image_medium = DIR_WS_IMAGES . 'medium/' . $products_image_base . IMAGE_SUFFIX_MEDIUM . $products_image_extension;
$products_image_large = DIR_WS_IMAGES . 'large/' . $products_image_base . IMAGE_SUFFIX_LARGE . $products_image_extension;
break;
default:
break;
}
}
}
Spoke too soon.
The .webp error are gone after doing the change to IHobserver but now i am getting an error with the pop up
Quote:
[29-Oct-2022 18:53:18 UTC] PHP Fatal error: Call to undefined function srttolower() in /includes/classes/observers/ImageHandlerObserver.php on line 107
[29-Oct-2022 18:53:18 UTC] Request URI: /index.php?main_page=popup_image&pID=785, IP address: 54.236.1.13
--> PHP Fatal error: Call to undefined function srttolower() in /includes/classes/observers/ImageHandlerObserver.php on line 107.
Re: Hover image alignment
That should be strtolower not srttolower sorry typo on line 107
Re: Hover image alignment
Quote:
Originally Posted by
brittainmark
That should be strtolower not srttolower sorry typo on line 107
Thank you very much
Re: Hover image alignment
Quote:
Originally Posted by
brittainmark
That should be strtolower not srttolower sorry typo on line 107
I am still getting the same errorregarding .webp .
Quote:
[30-Oct-2022 01:53:03 UTC] PHP Notice: Image Handler, calculate_size for /images/red_rose_with_hydrangea.webp returned false; image is corrupt. in /includes/classes/bmz_image_handler.class.php on line 484
[30-Oct-2022 01:53:03 UTC] PHP Notice: Image Handler, calculate_size for /images/red_rose_with_hydrangea.webp returned false; image is corrupt. in /includes/classes/bmz_image_handler.class.php on line 484
I am at loss here on what to do.
Any other suggestions? please
Thank you
Re: Hover image alignment
Have you got the full stack trace (logfile) so I can see where it was called from.
Re: Hover image alignment
Think I might have found it.
Try altering includes/functions/extra_functions/functions_bmz_image_handler.php
about line 114 from
Code:
function handle_image($src, $alt, $width, $height, $parameters)
{
global $ihConf;
if ($ihConf['resize']) { //Image Handler processing is enabled
to
Code:
function handle_image($src, $alt, $width, $height, $parameters)
{
global $ihConf;
$image_ext = strtolower(pathinfo($src, PATHINFO_EXTENSION));
if ($ihConf['resize'] && ($image_ext != 'webp')) { //Image Handler processing is enabled