VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: hazael on March 01, 2023, 16:00:45 PM

Title: Maybe bug in product edit - image
Post by: hazael on March 01, 2023, 16:00:45 PM
If I turn off the automatic generation of thumbnails in the Virtuemart settings, I can't see the graphics in the administration panel. Image links link to thumbnails that don't exist.

In general, I want to give up automatic thumbnail creation - it's an old solution that should be abandoned. Now the most optimal solution are adaptive images.
The size of the generated graphics should depend on the size of the screen - responsive images with srcset attribute.
In the case of the old solution, the photos are scaled (stretched) or too large and reduced


VirtueMart 4.0.12 10777
Title: Re: Maybe bug in product edit - image
Post by: StefanSTS on March 01, 2023, 18:37:15 PM
What graphics in administration panel exactly do you mean?
Do you have a screenshot?

Stefan
Title: Re: Maybe bug in product edit - image
Post by: Milbo on March 01, 2023, 18:54:27 PM
We have "adaptive" images already. It is just a matter of your template using it. Even the main image could be already a thumb. Vm creates for any given solution a new thumb

function displayMediaThumb($imageArgs=array(),$lightbox=true,$effect="rel='group'",$return = true,$withDescr = false,$absUrl = false, $width=0,$height=0){

Just fill the last two params and a new thumbnail with the correct size is generated. And of course you can leave one 0 to prevent distortion.
Title: Re: Maybe bug in product edit - image
Post by: pinochico on March 01, 2023, 20:14:33 PM
For seo is better load inside function last two value as calculate from thumb from FTP (and before define size in vm config)
Then your thumb images will be ok for google pagespeed insight.

The best option is add ratio for elmiminate CLS (again for google pagespeed insight).

Is very easy add as new params to this thumb function, value you have from calculate form size if thumb in FTP :)

P.S.
URL: administrator/components/com_virtuemart/helpers/mediahandler.php

function displayIt

add now code:


$size = getimagesize($_SERVER['DOCUMENT_ROOT'] . '/' . $this->file_url );



$image = '<img src="' . $image_href . '" alt="' . $file_alt . '" title="' . $file_alt . '" ' . $imageArgs . ' width="' . $size[0] . '" height="' . $size[1] . '" style="aspect-ratio: ' . $size[0] . ' / ' . $size[1] . '"/>';
Title: Re: Maybe bug in product edit - image
Post by: hazael on March 01, 2023, 22:31:55 PM
Thanks for the instant reply :)
Generally, I can't see some photos of products in the Virtuemart in product editing, if I disable thumbnail generation - looks a bit like a bug. Other than that, the site works realy good for me. :)


I didn't even know I could do this directly in Virtuemart - thanks for the tips - come in handy for the new page  :)
At the moment I'm using an external plugin to generate thumbnails. For example one picture now looks like this:

<img data-srcset="/images/virtuemart/product/image.webp 480w, /768/images/virtuemart/product/image.webp 768w, /992/images/virtuemart/product/image.webp 992w, /images/virtuemart/product/image.webp 1200w" sizes="100vw"
data-src="/images/virtuemart/product/image.webp"
srcset="/480/images/virtuemart/product/image.webp 480w, /768/images/virtuemart/product/image.webp 768w, /992/images/virtuemart/product/image.webp 992w, /images/virtuemart/product/image.webp 1200w"
src="/images/virtuemart/product/image.webp" />
Title: Re: Maybe bug in product edit - image
Post by: hazael on March 01, 2023, 23:14:50 PM
PS.

Milbo, do you plan to add categorization to product photos in the future? For me, the product page has several different types of images. They are displayed in different places.
My images are categorized by the name of the file description. But it's a bit inconvenient. It would be nice if there were real editable image categories for products.

for ($i = 1; $i < count($this->product->images); $i++) {$image = $this->product->images[$i];if (strpos($image->file_description, "type1") !== false){ $this->product->images[$i]->file_url; }}
Title: Re: Maybe bug in product edit - image
Post by: pinochico on March 02, 2023, 05:13:01 AM
QuoteAt the moment I'm using an external plugin to generate thumbnails. For example one picture now looks like this:

Yes, we use the external plugin too, but this plugin use our little hack in function DisplayIt.

For example one picture now looks like this:


<picture alt="CBD konopná směs 1,6% BIO 35g" class="featuredProductImage" border="0" style="aspect-ratio: 200 / 200;" height="150" width="150">
<source type="image/webp" srcset="/images/stories/virtuemart/product/resized/konopny_caj_biocbd_cz-sk__mockup2_200x200.webp" alt="CBD konopná směs 1,6% BIO 35g" class="featuredProductImage" border="0" style="aspect-ratio: 200 / 200;" height="150" width="150">
<source srcset="/images/stories/virtuemart/product/resized/konopny_caj_biocbd_cz-sk__mockup2_200x200.jpg" type="image/jpeg" alt="CBD konopná směs 1,6% BIO 35g" class="featuredProductImage" border="0" style="aspect-ratio: 200 / 200;" height="150" width="150">
<img src="/images/stories/virtuemart/product/resized/konopny_caj_biocbd_cz-sk__mockup2_200x200.jpg" alt="CBD konopná směs 1,6% BIO 35g" class="featuredProductImage" border="0" style="aspect-ratio: 200 / 200;" height="150" width="150">
</picture>