VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: dav3sh on October 15, 2015, 21:49:10 PM

Title: Use cropresize() function inside featured products module
Post by: dav3sh on October 15, 2015, 21:49:10 PM
Hi, is there a way to implement the function cropresize() (/libraries/joomla/image/image.php) into the featured module template? (/modules/mod_virtuemart_product/tmpl/default.php)
Thank you for answering
I am using  VM3.0.1 and Joomla!3.4.4
Title: Re: Use cropresize() function inside featured products module
Post by: dav3sh on October 16, 2015, 02:13:21 AM
I found this useful post
http://forum.virtuemart.net/index.php?topic=112636.0



if (!empty($product->images[0]) && is_a($product->images[0],'VmImage')) {
//$image = $product->images[0]->displayMediaThumb ('class="featuredProductImage" border="0"', FALSE);
$width=141;//your width
$height=195;//your height
$prod_img = &$product->images[0];
$file_name_thumb = $prod_img->createThumbName($width,$height);
$resizedImage_url = $prod_img->file_url_folder_thumb.$file_name_thumb.'.'.$prod_img->file_extension;
if (!file_exists($resizedImage_url)) {
$resizedImage_url = $prod_img->createThumb($width,$height);
}
$image = JHTML::image(JURI::root().$resizedImage_url, '', '');
} else {
$image = '';
}


There is the code to resize the images.. maybe it is possible to implement the crop function too?
Thank you anyway
Title: Re: Use cropresize() function inside featured products module
Post by: dav3sh on October 16, 2015, 02:50:55 AM
In joomla core it looks like there is this function. It's a @param integer - $creationMethod - inside the createThumbs function. So when you're creating a thumb you can set it to 5 and you will get the resize and crop function. But I don't know if the createThumb of VM is the same of Joomla (I don't think so as there is a missing s in the vm function). Neither where to put this '5' in my previous code.
I've tried here:

$resizedImage_url = $prod_img->createThumb($width,$height,5);

But it doesn't work.
Thank you