News:

Looking for documentation? Take a look on our wiki

Main Menu

SVG images

Started by pivovary, November 02, 2023, 15:17:13 PM

Previous topic - Next topic

pivovary

Hi,
i need use SVG image file in product but missing me thumb in images tab.
Screen is in attachment.

Virtuemart 4.2.4

jenkinhill

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

pivovary

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?

hazael

#3
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..)