VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: AbsoluteVM on February 01, 2013, 18:02:53 PM

Title: Custom thumbnail size?
Post by: AbsoluteVM on February 01, 2013, 18:02:53 PM
Can you utilise a custom size for templating?

I don't want everything to be the same size. Do I have to use a external image handler?

If I use:
<?php echo $manufacturer->images[0]->displayMediaThumb('',false);?>

It will only output the config'd size..
Title: Re: Custom thumbnail size?
Post by: K&K media production on February 01, 2013, 18:25:20 PM
You can use css.

In configuration set the biggest size for the thumbs. Then with css you can resize the images.

Example:

img.browseProductImage {width: 100px;}
Title: Re: Custom thumbnail size?
Post by: AbsoluteVM on February 03, 2013, 23:00:11 PM
Thanks for your reply.

I guess I can use CSS, but it feels like this is fairly bad practice when i'm resizing a large image on every page...

Do there is no internal syntax that I can use for displayMediaThumb that will crop/resize?
Title: Re: Custom thumbnail size?
Post by: K&K media production on February 03, 2013, 23:17:27 PM
No. Either you use the size from your config for each or you set up the size for the biggest thumb in the config and resize the smaller ones with css. So you can have a css class for categories, products and so on...
Title: Re: Custom thumbnail size?
Post by: AbsoluteVM on February 05, 2013, 10:32:44 AM
Is the VM system for images being improved? That's mickey mouse, loading a large thumbnail for a possibly smaller image...

I want to do it on the fly so I'm not using a 100KB image for what could be a 10KB image.
Title: Re: Custom thumbnail size?
Post by: jenkinhill on February 05, 2013, 17:35:06 PM
I set the thumbs to be generated at the largest size I am likely to need, and  use max-width in css where needed to control the width without affecting the width/height proportions. I guess you could use min-width in the same way, but that does cause some loss of resolution with too small images.
Title: Re: Custom thumbnail size?
Post by: anisimow on February 27, 2013, 09:40:39 AM
Quote from: AbsoluteVM on February 01, 2013, 18:02:53 PM
Can you utilise a custom size for templating?

I don't want everything to be the same size. Do I have to use a external image handler?

If I use:
<?php echo $manufacturer->images[0]->displayMediaThumb('',false);?>

It will only output the config'd size..

try this only for product  images

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 = '';
}
Title: Re: Custom thumbnail size?
Post by: AbsoluteVM on March 04, 2013, 12:00:54 PM
Hello, is that core ? That seems exactly what I need if it is CORE.
Title: Re: Custom thumbnail size?
Post by: anisimow on March 05, 2013, 15:27:26 PM
Quote from: AbsoluteVM on March 04, 2013, 12:00:54 PM
Hello, is that core ? That seems exactly what I need if it is CORE.
It is taken from  core. Uou can use it wenever you want.
Title: Re: Custom thumbnail size?
Post by: baggiesmad on September 11, 2013, 11:21:55 AM
Fantastic! Thanks anisimow
Title: Re: Custom thumbnail size?
Post by: jukov_b1 on March 02, 2016, 00:32:40 AM
anisimow many thanks for the fine decision
works at the Joomla version! 2.5.27 + VirtueMart 2.6.10