image type
-
Hello, using your plugin, which works quite well in my case, I noticed that the converted files change the extension, but the file type remains JPG. This creates some strange behavior with certain plugins. For example, RevSlider starts spamming this warning:
wp-content/plugins/revslider/includes/aq-resizer.class.php on line 99 PHP Warning: Trying to access array offset on value of type bool in
and media.php throws this:
[04-Nov-2024 08:10:41 UTC] PHP Warning: foreach() argument must be of type array|object, null given in /wp-admin/includes/media.php on line 1965
This is a converted file:
Name:?progetto-giovani-2-scaled.webp
Type:?image/jpeg
Dimension:?356 KB
Size:?2560 per 1920 pixel
Other file keep extension like this
Nome file:?34149-jpg.webp
Tipo di file:?image/jpeg
-
can anyone help me?
is it a normal behavior of the plugin that the file type remains image/jpeg after conversion or it only happens to me- This reply was modified 2 weeks, 5 days ago by patrikmuse.
Thanks for reaching out @patrikmuse, and apologies for the late replay. When the plugin generates a WebP or AVIF version of an image, it’s using the
-jpeg
reference in the image you reference to help identify that the original image was a JPEG.Regarding this appearing as a image/jpeg file type, is this from your hosting control panel or elsewhere? Please share where you’re seeing this file type and we can check further, or check how the image appears from an FTP program.
These are the metadata of an image converted with your plugin. Some sources remain as
image/jpeg
instead ofimage/avif
, causing issues with certain plugins, such as this section of code from RevSlider:// Check if $img_url is local.
if ( false === strpos( $url, $upload_url ) ) return false;// Define path of image. $rel_path = str_replace( $upload_url, '', $url ); $img_path = $upload_dir . $rel_path; // Check if img path exists, and is an image indeed. if ( ! file_exists( $img_path ) or ! @getimagesize( $img_path ) ) return false; // Get image info. $info = pathinfo( $img_path ); $ext = $info['extension']; list( $orig_w, $orig_h ) = getimagesize( $img_path ); // Get image size after cropping. $dims = image_resize_dimensions( $orig_w, $orig_h, $width, $height, $crop ); $dst_w = $dims[4]; $dst_h = $dims[5];
Give this warning[05-Nov-2024 14:25:55 UTC] PHP Warning: Trying to access array offset on value of type bool in /home/fcitestadm1n/public_html/wp-content/plugins/revslider/includes/aq-resizer.class.php on line 99
[05-Nov-2024 14:25:55 UTC] PHP Warning: Trying to access array offset on value of type bool in /home/fcitestadm1n/public_html/wp-content/plugins/revslider/includes/aq-resizer.class.php on line 100
a:8:{s:5:”width”;i:2000;s:6:”height”;i:1333;s:4:”file”;s:50:”2024/11/WhatsApp-Image-2024-11-03-at-17.09.20.jpeg”;s:8:”filesize”;i:290692;s:5:”sizes”;a:11:{s:9:”thumbnail”;a:6:{s:4:”file”;s:50:”WhatsApp-Image-2024-11-03-at-17.09.20-150×150.avif”;s:5:”width”;i:150;s:6:”height”;i:150;s:9:”mime-type”;s:10:”image/avif”;s:8:”filesize”;i:9060;s:7:”sources”;a:1:{s:10:”image/avif”;a:2:{s:4:”file”;s:50:”WhatsApp-Image-2024-11-03-at-17.09.20-150×150.avif”;s:8:”filesize”;i:9060;}}}s:6:”medium”;a:6:{s:4:”file”;s:50:”WhatsApp-Image-2024-11-03-at-17.09.20-300×200.avif”;s:5:”width”;i:300;s:6:”height”;i:200;s:9:”mime-type”;s:10:”image/avif”;s:8:”filesize”;i:19674;s:7:”sources”;a:1:{s:10:”image/avif”;a:2:{s:4:”file”;s:50:”WhatsApp-Image-2024-11-03-at-17.09.20-300×200.avif”;s:8:”filesize”;i:19674;}}}s:12:”medium_large”;a:6:{s:4:”file”;s:50:”WhatsApp-Image-2024-11-03-at-17.09.20-768×512.avif”;s:5:”width”;i:768;s:6:”height”;i:512;s:9:”mime-type”;s:10:”image/avif”;s:8:”filesize”;i:69315;s:7:”sources”;a:1:{s:10:”image/avif”;a:2:{s:4:”file”;s:50:”WhatsApp-Image-2024-11-03-at-17.09.20-768×512.avif”;s:8:”filesize”;i:69315;}}}s:5:”large”;a:6:{s:4:”file”;s:51:”WhatsApp-Image-2024-11-03-at-17.09.20-1024×682.avif”;s:5:”width”;i:1024;s:6:”height”;i:682;s:9:”mime-type”;s:10:”image/avif”;s:8:”filesize”;i:102342;s:7:”sources”;a:1:{s:10:”image/avif”;a:2:{s:4:”file”;s:51:”WhatsApp-Image-2024-11-03-at-17.09.20-1024×682.avif”;s:8:”filesize”;i:102342;}}}s:9:”1536×1536″;a:5:{s:4:”file”;s:52:”WhatsApp-Image-2024-11-03-at-17.09.20-1536×1024.avif”;s:5:”width”;i:1536;s:6:”height”;i:1024;s:9:”mime-type”;s:10:”image/avif”;s:8:”filesize”;i:177456;}s:14:”post-thumbnail”;a:5:{s:4:”file”;s:50:”WhatsApp-Image-2024-11-03-at-17.09.20-360×210.avif”;s:5:”width”;i:360;s:6:”height”;i:210;s:9:”mime-type”;s:10:”image/avif”;s:8:”filesize”;i:22427;}s:27:”konte-post-thumbnail-medium”;a:5:{s:4:”file”;s:50:”WhatsApp-Image-2024-11-03-at-17.09.20-580×400.avif”;s:5:”width”;i:580;s:6:”height”;i:400;s:9:”mime-type”;s:10:”image/avif”;s:8:”filesize”;i:48635;}s:26:”konte-post-thumbnail-large”;a:5:{s:4:”file”;s:50:”WhatsApp-Image-2024-11-03-at-17.09.20-750×420.avif”;s:5:”width”;i:750;s:6:”height”;i:420;s:9:”mime-type”;s:10:”image/avif”;s:8:”filesize”;i:58244;}s:31:”konte-post-thumbnail-navigation”;a:5:{s:4:”file”;s:49:”WhatsApp-Image-2024-11-03-at-17.09.20-100×68.avif”;s:5:”width”;i:100;s:6:”height”;i:68;s:9:”mime-type”;s:10:”image/avif”;s:8:”filesize”;i:4076;}s:30:”konte-post-thumbnail-shortcode”;a:5:{s:4:”file”;s:50:”WhatsApp-Image-2024-11-03-at-17.09.20-450×300.avif”;s:5:”width”;i:450;s:6:”height”;i:300;s:9:”mime-type”;s:10:”image/avif”;s:8:”filesize”;i:34459;}s:12:”tg-landscape”;a:5:{s:4:”file”;s:50:”WhatsApp-Image-2024-11-03-at-17.09.20-800×600.avif”;s:5:”width”;i:800;s:6:”height”;i:600;s:9:”mime-type”;s:10:”image/avif”;s:8:”filesize”;i:76180;}}s:10:”image_meta”;a:12:{s:8:”aperture”;s:1:”0″;s:6:”credit”;s:0:””;s:6:”camera”;s:0:””;s:7:”caption”;s:0:””;s:17:”created_timestamp”;s:1:”0″;s:9:”copyright”;s:0:””;s:12:”focal_length”;s:1:”0″;s:3:”iso”;s:1:”0″;s:13:”shutter_speed”;s:1:”0″;s:5:”title”;s:0:””;s:11:”orientation”;s:1:”0″;s:8:”keywords”;a:0:{}}s:7:”sources”;a:1:{s:10:”image/jpeg“;a:2:{s:4:”file”;s:47:”WhatsApp-Image-2024-11-03-at-17.09.20-jpeg.avif”;s:8:”filesize”;i:251587;}}s:14:”original_image”;s:42:”WhatsApp-Image-2024-11-03-at-17.09.20.jpeg”;}https://phpfci.ksport.kgroup.eu/avifbug.png
you can see the image in media from my wordpress- This reply was modified 2 weeks, 4 days ago by patrikmuse.
Appreciate the additional screenshot @patrikmuse. I’ve been performing some checks on this and while the media file manager in WordPress may display the mime type as a jpg (example), this is only WordPress core referencing the original image, as noted in this comment on a related GitHub issue.
To summarize, the AVIF image is used, it’s just the original JPEG image may be referenced in your media manager, which may be more suitable, as opposed to displaying different formats of the same image.
Okay, all clear, but this behavior with converted images leads the plugins to unexpected responses, like this:
[10-Nov-2024 02:45:08 UTC] PHP Warning: Trying to access array offset on value of type bool in/public_html/wp-content/plugins/revslider/includes/aq-resizer.class.php on line 99 [10-Nov-2024 02:45:08 UTC] PHP Warning: Trying to access array offset on value of type bool in /public_html/wp-content/plugins/revslider/includes/aq-resizer.class.php on line 100
If I upload an image in webp or avif format, the plugin works correctly, but if I convert it with yours, this happens, and I can’t understand why. I get extreme spam of these warnings.
The code part is this// Check if $img_url is local.
if ( false === strpos( $url, $upload_url ) ) return false;// Define path of image.
$rel_path = str_replace( $upload_url, '', $url );
$img_path = $upload_dir . $rel_path;
// Check if img path exists, and is an image indeed.
if ( ! file_exists( $img_path ) or ! @getimagesize( $img_path ) ) return false;
// Get image info.
$info = pathinfo( $img_path );
$ext = $info['extension'];
list( $orig_w, $orig_h ) = getimagesize( $img_path );
// Get image size after cropping.
$dims = image_resize_dimensions( $orig_w, $orig_h, $width, $height, $crop );
line 99 $dst_w = $dims[4];
line 100 $dst_h = $dims[5];
- You must be logged in to reply to this topic.