News:

Support the VirtueMart project and become a member

Main Menu

webp no fully support in VM

Started by vdweb.cz, April 10, 2024, 19:10:32 PM

Previous topic - Next topic

vdweb.cz

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.

vdweb.cz

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'){

Milbo

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.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

alxgan

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;

   }

Milbo

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

T.A. Garrison, LLC

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.
T.A. Garrison, LLC
3150 Orleans St. # 28261
Bellingham, WA 98228