Author Topic: Custom thumbnail size?  (Read 4571 times)

AbsoluteVM

  • Jr. Member
  • **
  • Posts: 85
Custom thumbnail size?
« 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..

K&K media production

  • VirtueMart Developer Team
  • Global Moderator
  • Full Member
  • *
  • Posts: 838
  • VirtueMart Version: VM3 on J3
Re: Custom thumbnail size?
« Reply #1 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;}

AbsoluteVM

  • Jr. Member
  • **
  • Posts: 85
Re: Custom thumbnail size?
« Reply #2 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?

K&K media production

  • VirtueMart Developer Team
  • Global Moderator
  • Full Member
  • *
  • Posts: 838
  • VirtueMart Version: VM3 on J3
Re: Custom thumbnail size?
« Reply #3 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...

AbsoluteVM

  • Jr. Member
  • **
  • Posts: 85
Re: Custom thumbnail size?
« Reply #4 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.

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 27674
  • Always on vacation
    • Jenkin Hill Internet
Re: Custom thumbnail size?
« Reply #5 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.
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

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

Currently using VM 3.6.11 10292 on Joomla 3.9.16 PHP 7.0.33

anisimow

  • Beginner
  • *
  • Posts: 21
  • Skype Name: anisimowsjava
Re: Custom thumbnail size?
« Reply #6 on: February 27, 2013, 09:40:39 am »
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
Code: [Select]
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

  • Jr. Member
  • **
  • Posts: 85
Re: Custom thumbnail size?
« Reply #7 on: March 04, 2013, 12:00:54 pm »
Hello, is that core ? That seems exactly what I need if it is CORE.

anisimow

  • Beginner
  • *
  • Posts: 21
  • Skype Name: anisimowsjava
Re: Custom thumbnail size?
« Reply #8 on: March 05, 2013, 15:27:26 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

  • Jr. Member
  • **
  • Posts: 308
Re: Custom thumbnail size?
« Reply #9 on: September 11, 2013, 11:21:55 am »
Fantastic! Thanks anisimow

jukov_b1

  • Beginner
  • *
  • Posts: 1
  • Skype Name: jukov_b1
Re: Custom thumbnail size?
« Reply #10 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