VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: pivovary on November 02, 2023, 15:17:13 PM

Title: SVG images
Post by: pivovary on November 02, 2023, 15:17:13 PM
Hi,
i need use SVG image file in product but missing me thumb in images tab.
Screen is in attachment.

Virtuemart 4.2.4
Title: Re: SVG images
Post by: jenkinhill on November 02, 2023, 16:08:29 PM
The server GD2 library does not support the .svg format - and VM uses GD2 to create thumbs.

For using .svg image files for products see http://forum.virtuemart.net/index.php?topic=146852.msg535194#msg535194
Title: Re: SVG images
Post by: pivovary on November 03, 2023, 09:16:26 AM
I'm so sorry but this is big problem create control function in PHP and don't create thumb if is SVG and show it?
Title: Re: SVG images
Post by: hazael on November 09, 2023, 18:57:58 PM
Quote from: jenkinhill on November 02, 2023, 16:08:29 PM
The server GD2 library does not support the .svg format - and VM uses GD2 to create thumbs.
SVG is a vector file and there is no need to make thumbnails at all, because the vector file is scalable from 1px to infinity

The lack of SVG support in Virtuemart is nothing more than the developer's ignorance.

There is a quite simple solution to this.
Upload raster files in jpg/png format to Virtuemart normally, and place SVG files with the same name in a separate folder.

in my case the equivalent of a folder
/images/virtuemart/product
is
/images/virtuemart/svg

in virtuemart template add this code to any php file which is in this path ../com_virtuemart/productdetails/

for ($i = 1; $i < count($this->product->images); $i++) {
$jpg = $this->product->images[$i]->file_url;
$svg = str_replace(array('.png', '.jpg', 'product'), array('.svg', '.svg', 'svg'), $jpg)


$test = file_exists($svg);

<?php
if (!$test) { ?>

<img  src="<?php echo JURI::root().$jpg?>"/>
<?php } else { ?>
<img src="<?php echo JURI::root().$svg?>"/>
<?php }} ?>



For me, this solution with identical graphics in png and SVG format makes sense, because on my website I only display SVG, but I export the link to images in png format with an identical image separately to an XML file for other domains where svg files are not accepted (amazon /ebay etc..)