Author Topic: Image resize, more variations  (Read 438 times)

EvanGR

  • Jr. Member
  • **
  • Posts: 153
Image resize, more variations
« on: September 24, 2018, 09:28:13 am »
Hello,

Virtuemart, by default, offers a single fixed resolution image resize for thumbnails. Have you (the devs) considered including more variations in the future?

With the use of the <picture> element, one can now define multiple resolutions for an image in the browser.

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/picture

Thanks

StefanSTS

  • Global Moderator
  • Jr. Member
  • *
  • Posts: 223
  • VirtueMart Version: VM 4.2 on Joomla 4.5
Re: Image resize, more variations
« Reply #1 on: September 24, 2018, 09:42:43 am »
VirtueMart has a function to resize the images as per your need.

If you need more resolutions you can adjust your template accordingly. Just check the productdetails view.

You find this in the files:

echo $image->displayMediaThumb("",true,"rel='vm-additional-images'", true, true, false, $width, $height);

Stefan
--
Stefan Schumacher
www.jooglies.com - VirtueMart Invoice Layouts

EvanGR

  • Jr. Member
  • **
  • Posts: 153
Re: Image resize, more variations
« Reply #2 on: September 24, 2018, 11:45:38 am »
Hello and thanks.

Does this create additional thumbnails in the images folder?
If so, are they re-used next time, if found by subsequent page loads?

Thanks

StefanSTS

  • Global Moderator
  • Jr. Member
  • *
  • Posts: 223
  • VirtueMart Version: VM 4.2 on Joomla 4.5
Re: Image resize, more variations
« Reply #3 on: September 24, 2018, 11:57:59 am »
They will be in the resized/ folder and will be re-used.
--
Stefan Schumacher
www.jooglies.com - VirtueMart Invoice Layouts

EvanGR

  • Jr. Member
  • **
  • Posts: 153
Re: Image resize, more variations
« Reply #4 on: September 26, 2018, 12:13:05 pm »
Thanks again.

How can I tweak this code so that I just generate and use the thumbnail filename, but not display it? (VM creates its own img element)

I like to construct my own custom <img /> elements, with additional lazy-loading code and utilizing the <picture> element for image sets.

StefanSTS

  • Global Moderator
  • Jr. Member
  • *
  • Posts: 223
  • VirtueMart Version: VM 4.2 on Joomla 4.5
Re: Image resize, more variations
« Reply #5 on: September 26, 2018, 18:08:27 pm »
Hi,

never did it that way, but I guess you could call the function for a variable instead of echo'ing it.

$myhiddenimages = $image->displayMediaThumb(... $width, $height);

The thumbs should be generated then and you can access them by name. As I said, I never tried it. Maybe keep vmdebug on and check the messages and memory usage.

Stefan
--
Stefan Schumacher
www.jooglies.com - VirtueMart Invoice Layouts

EvanGR

  • Jr. Member
  • **
  • Posts: 153
Re: Image resize, more variations
« Reply #6 on: October 02, 2018, 08:44:02 am »
Hi,

never did it that way, but I guess you could call the function for a variable instead of echo'ing it.

$myhiddenimages = $image->displayMediaThumb(... $width, $height);

The thumbs should be generated then and you can access them by name. As I said, I never tried it. Maybe keep vmdebug on and check the messages and memory usage.

Stefan

How would I get the filename (and the image URL perhaps) of the generated thumbnail, if I have several variations of them?

Thanks

StefanSTS

  • Global Moderator
  • Jr. Member
  • *
  • Posts: 223
  • VirtueMart Version: VM 4.2 on Joomla 4.5
Re: Image resize, more variations
« Reply #7 on: October 03, 2018, 23:49:00 pm »
Just look in the resized folder inside of the images folders for products, categories and so on.

They have an ending according to their size. So it might be: /way/to/images/virtuemart/product/resized/myimage_90x90.jpg

--
Stefan Schumacher
www.jooglies.com - VirtueMart Invoice Layouts

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9743
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Image resize, more variations
« Reply #8 on: October 07, 2018, 12:51:14 pm »

How would I get the filename (and the image URL perhaps) of the generated thumbnail, if I have several variations of them?

Thanks

You do not really need it. Just use the function displayMediaThumb and set your desired size and it will be generated on the fly and when it exists already, it will use the already existing one, of course. So you do not need to fuddle around with the different thumbsizes. When you replace or some how change your main media, all thumbs of the media (and maybe some more) will be deleted automatically.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 8592
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 2.6.22 & 3.2.14
Re: Image resize, more variations
« Reply #9 on: October 07, 2018, 14:37:42 pm »
for your lazy load can't u use  $imgthumb = JURI::root() . $product->images[0]->getFileUrlThumb();

the function takes sizes as well

function getFileUrlThumb($width = 0,$height = 0)

haven't tried though
GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation