From 7eacfab90d21b0240730484ab59719f1ea351f2b Mon Sep 17 00:00:00 2001 From: Zeke Farwell Date: Fri, 15 Feb 2019 17:05:06 -0500 Subject: [PATCH] Use generated thumbnail image instead of originally uploaded file --- .../Widget/Grid/Column/Renderer/Image.php | 2 +- .../community/TBT/Enhancedgrid/Helper/Data.php | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/app/code/community/TBT/Enhancedgrid/Block/Widget/Grid/Column/Renderer/Image.php b/app/code/community/TBT/Enhancedgrid/Block/Widget/Grid/Column/Renderer/Image.php index 85f260f..03b8156 100644 --- a/app/code/community/TBT/Enhancedgrid/Block/Widget/Grid/Column/Renderer/Image.php +++ b/app/code/community/TBT/Enhancedgrid/Block/Widget/Grid/Column/Renderer/Image.php @@ -80,7 +80,7 @@ protected function _getValue(Varien_Object $row) $val = $val2 = $row->getData($this->getColumn()->getIndex()); $val = str_replace('no_selection', '', $val); $val2 = str_replace('no_selection', '', $val2); - $url = Mage::helper('enhancedgrid')->getImageUrl($val); + $url = Mage::helper('enhancedgrid')->getImageUrl($val, $row); if (!Mage::helper('enhancedgrid')->getFileExists($val)) { $dored = true; diff --git a/app/code/community/TBT/Enhancedgrid/Helper/Data.php b/app/code/community/TBT/Enhancedgrid/Helper/Data.php index 01a01e4..e5dbfe3 100644 --- a/app/code/community/TBT/Enhancedgrid/Helper/Data.php +++ b/app/code/community/TBT/Enhancedgrid/Helper/Data.php @@ -2,11 +2,23 @@ class TBT_Enhancedgrid_Helper_Data extends Mage_Core_Helper_Abstract { - public function getImageUrl($image_file) + /** + * Get url of cached thumbnail image + * Will generate cached image if doesn't exist + * + * @param string $image_file + * @param Mage_Catalog_Model_Product $product + * @return bool|string + */ + public function getImageUrl($image_file, $product) { $url = false; - $url = Mage::getBaseUrl('media').'catalog/product'.$image_file; - + if (!empty($image_file)) { + $helper = Mage::helper('catalog/image')->init($product, 'thumbnail'); + $width = Mage::getStoreConfig( 'enhancedgrid/images/width'); + $height = Mage::getStoreConfig( 'enhancedgrid/images/height'); + $url = $helper->resize($width, $height)->__toString(); + } return $url; }