VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: vdweb.cz on April 10, 2024, 19:10:32 PM

Title: webp no fully support in VM
Post by: vdweb.cz on April 10, 2024, 19:10:32 PM
Hi in 4.2.6 10972 you have write in upload image this text:

Supported filetypes for thumbnail creation GIF, JPG, PNG, WBMP, WEBP

But when you click on: Select a file -> WEBP is not in support list...

Even if you click on all file types and upload webp after that VM dont create thumbnail.
Title: Re: webp no fully support in VM
Post by: vdweb.cz on May 08, 2024, 17:59:50 PM
Hi in 4.2.8 11000 is not WEBP support

here is the solution in few rows:

administrator/components/com_virtuemart/helpers/img2thumb.php

AFTER ROW 215 ADD:
                case "webp":
                    if( function_exists("imagecreatefromwebp") ) {
                        $orig_img = imagecreatefromwebp($filename);
                    } else {
                        $app = JFactory::getApplication();
                        $app->enqueueMessage('This server does NOT suppport auto generating Thumbnails by webp');
                        return false;
                    }
                    break;





AFTER ROW 434 ADD:

            case "webp":
                if (strtolower(substr($fileout,strlen($fileout)-5,5))!=".webp")
                    $fileout .= ".webp";
                return imagewebp($new_img,$fileout);
                break;



AFTER ROW 476 ADD:

case "webp":
header ("Content-type: image/webp");
return imagewebp($new_img);
break;



AND in file
administrator/components/com_virtuemart/helpers/mediahandler.php

FIND
if($file_extension == 'jpg' || $file_extension == 'jpeg' || $file_extension == 'png' || $file_extension == 'gif'){
REPLACE
if($file_extension == 'jpg' || $file_extension == 'jpeg' || $file_extension == 'png' || $file_extension == 'gif' || $file_extension == 'webp'){
Title: Re: webp no fully support in VM
Post by: Milbo on May 12, 2024, 21:35:59 PM
Thank you,
great work. I wonder if the prior patch was working for imagecreatefromstring. I added it to the code and will committ it next time.
Title: Re: webp no fully support in VM
Post by: alxgan on August 04, 2024, 01:06:42 AM
maybe GetImgType from img2thumb.php should also be updated:
private function GetImgType($filename)
   {
        $imageExtensionsArray = array(
            IMAGETYPE_GIF => 'gif',
            IMAGETYPE_JPEG => 'jpg',
            IMAGETYPE_PNG => 'png',
            IMAGETYPE_SWF => 'swf',
            IMAGETYPE_PSD => 'psd',
            IMAGETYPE_BMP => 'bmp',
            IMAGETYPE_TIFF_II => 'tiff',
            IMAGETYPE_TIFF_MM => 'tiff',
            IMAGETYPE_JPC => 'jpc',
            IMAGETYPE_JP2 => 'jp2',
            IMAGETYPE_JPX => 'jpx',
            IMAGETYPE_JB2 => 'jb2',
            IMAGETYPE_SWC => 'swc',
            IMAGETYPE_IFF => 'iff',
            IMAGETYPE_WBMP => 'wbmp',
            IMAGETYPE_XBM => 'xbm',
            IMAGETYPE_ICO => 'ico',
            IMAGETYPE_WEBP => 'webp',
            IMAGETYPE_AVIF => 'avif'
        );

      $info = getimagesize($filename);
        if (isset($imageExtensionsArray[$info[2]])){
            return $imageExtensionsArray[$info[2]];
        }
        else return false;

   }
Title: Re: webp no fully support in VM
Post by: Milbo on August 07, 2024, 14:29:57 PM
Thank you, good idea.
Title: Re: webp no fully support in VM
Post by: T.A. Garrison, LLC on August 29, 2024, 01:50:29 AM
I'm not sure if this is the best place to ask, but because this is the update (already implemented, thank you, Max) for webp format, "where" would I update the mimetype for webp?

It's not something in Joomla because the mimetype is already there.

I've looked through the fancybox files and no mimetype information in those files.

It's not critical, it's just driving me crazy every time I upload a webp VM gives me the warning that there is no mimetype for the webp format.

If I only had to see it a few times that wouldn't be so bad. But I'm going to see it thousands of times in the next few months.

Thank you.