Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use generated thumbnail image instead of original image file #70

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 15 additions & 3 deletions app/code/community/TBT/Enhancedgrid/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down