News:

Support the VirtueMart project and become a member

Main Menu

Custom thumbnail size?

Started by AbsoluteVM, February 01, 2013, 18:02:53 PM

Previous topic - Next topic

AbsoluteVM

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..

K&K media production

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;}

AbsoluteVM

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?

K&K media production

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...

AbsoluteVM

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.

jenkinhill

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.
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

anisimow

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 = '';
}

AbsoluteVM

Hello, is that core ? That seems exactly what I need if it is CORE.

anisimow

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.

baggiesmad


jukov_b1

anisimow many thanks for the fine decision
works at the Joomla version! 2.5.27 + VirtueMart 2.6.10