cancel
Showing results for 
Search instead for 
Did you mean: 

Error filtering template: Notice: Undefined variable: secureRenderer in image_with_borders.phtml

Error filtering template: Notice: Undefined variable: secureRenderer in image_with_borders.phtml

hi i need fix this error please 

 

Error filtering template: Notice: Undefined variable: secureRenderer in /home/user/public_html/app/design/frontend/Sm/themecore/Magento_Catalog/templates/product/image_with_borders.phtml on line 89
 
the line 89 
<?= /* @noEscape */
$secureRenderer->renderTag('style', [], $styles, false) ?>
 
 
all code
 

<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
?>
<?php
/** @var $block \Magento\Catalog\Block\Product\Image */
/** @var $escaper \Magento\Framework\Escaper */
/** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */
/**
* Enable lazy loading for images with borders and if variable enable_lazy_loading_for_images_without_borders
* is enabled in view.xml. Otherwise small size images without borders may be distorted. So max-width is used for them
* to prevent stretching and lazy loading does not work.
*/
$borders = (bool)$block->getVar('product_image_white_borders', 'Magento_Catalog');
$enableLazyLoadingWithoutBorders = (bool)$block->getVar(
'enable_lazy_loading_for_images_without_borders',
'Magento_Catalog'
);
$width = (int)$block->getWidth();
$paddingBottom = $block->getRatio() * 100;
$_config = $this->helper('Sm\Themecore\Helper\Data');
$enableLadyLoading = $_config->getAdvanced('lazyload_group/enable_ladyloading');
$mediaSrc = $_config->getMediaUrl();
if ($enableLadyLoading) {
$imgClass = 'lazyload';
} else {
$imgClass = '';
}
?>
<span class="product-image-container product-image-container-<?= /* @noEscape */
$block->getProductId() ?>" style="width: <?php echo $width . "px"; ?>">
<span class="product-image-wrapper">
<img class="<?= $escaper->escapeHtmlAttr($block->getClass()) ?> <?php echo $imgClass; ?>"
<?php foreach ($block->getCustomAttributes() as $name => $value): ?>
<?= $escaper->escapeHtmlAttr($name) ?>="<?= $escaper->escapeHtmlAttr($value) ?>"
<?php endforeach; ?>

<?php if ($enableLadyLoading) { ?>
src="<?php echo $mediaSrc . 'lazyloading/blank.png'; ?>"
data-src="<?= $escaper->escapeUrl($block->getImageUrl()) ?>"
<?php } else { ?>
src="<?= $escaper->escapeUrl($block->getImageUrl()) ?>"
<?php } ?>

loading="lazy"
<?php if ($borders || $enableLazyLoadingWithoutBorders): ?>
width="<?= $escaper->escapeHtmlAttr($block->getWidth()) ?>"
height="<?= $escaper->escapeHtmlAttr($block->getHeight()) ?>"
<?php else: ?>
max-width="<?= $escaper->escapeHtmlAttr($block->getWidth()) ?>"
max-height="<?= $escaper->escapeHtmlAttr($block->getHeight()) ?>"
<?php endif; ?>
alt="<?= $escaper->escapeHtmlAttr($block->getLabel()) ?>"/></span>
</span>
<?php
$styles = <<<STYLE
/**
.product-image-container-{$block->getProductId()} {
width: {$width}px;
}
*/
.product-image-container-{$block->getProductId()} span.product-image-wrapper {
padding-bottom: {$paddingBottom}%;
}
STYLE;
//In case a script was using "style" attributes of these elements
$script = <<<SCRIPT
prodImageContainers = document.querySelectorAll(".product-image-container-{$block->getProductId()}");
/**
for (var i = 0; i < prodImageContainers.length; i++) {
prodImageContainers[i].style.width = "{$width}px";
}
*/
prodImageContainersWrappers = document.querySelectorAll(
".product-image-container-{$block->getProductId()} span.product-image-wrapper"
);
for (var i = 0; i < prodImageContainersWrappers.length; i++) {
prodImageContainersWrappers[i].style.paddingBottom = "{$paddingBottom}%";
}
SCRIPT;

?>

<?= /* @noEscape */
$secureRenderer->renderTag('style', [], $styles, false) ?>
<?= /* @noEscape */
$secureRenderer->renderTag('script', ['type' => 'text/javascript'], $script, false) ?>

 
 
1 REPLY 1

Re: Error filtering template: Notice: Undefined variable: secureRenderer in image_with_borders.phtml

Hello @egygol2244c781 

 

It seems your Magento version did not support $secureRenderer variable yet which available since Magento 2.4.0

 

$secureRenderer is an instance of \Magento\Framework\View\Helper\SecureHtmlRenderer class to render HTML elements with consideration to application security. So you can remove the implementation for $secureRenderer from the third-party extension to allow their code to work on your site. Remember to revert the changes once you upgrade your site to Magento version >=2.4.0

 

To remove the implementation for $secureRenderer from the third-party extension, replace the code in that file:

 

<p> <a href="#" id="linkId" title="<?= $block->escapeHtmlAttr(__('Track Order')) ?>"> <?= $block->escapeHtml(__('Track Order')) ?> </a> </p> 


<?= /* @noEscape */ $secureRenderer->renderEventListenerAsTag( 'onclick', "popWin('" . $block->escapeJs($shippingHelper->getTrackingPopupUrlBySalesModel($order)) . "','trackorder','width=800,height=600,resizable=yes,scrollbars=yes')", 'a#linkId' ) ?>

Hope it helps !

If you find our reply helpful, please give us kudos.

 

A Leading Magento Development Agency That Delivers Powerful Results, Innovation, and Secure Digital Transformation.

 

WebDesk Solution Support Team

Get a Free Quote | | Adobe Commerce Partner | Hire Us | Call Us 877.536.3789

 

Thank You,


WebDesk Solution Support Team
Get a Free Quote | Email | Adobe Commerce Partner | Hire Us | Call Us 877.536.3789


Location: 150 King St. W. Toronto, ON M5H 1J9