WPChill / modula-lite

https://wordpress.org/plugins/modula-best-grid-gallery/
GNU General Public License v3.0
18 stars 9 forks source link

Undefined index: mime-type #573

Open mplusb opened 3 years ago

mplusb commented 3 years ago

Describe the bug I’m getting a PHP notice several times in debug.log:

[29-Apr-2021 23:06:57 UTC] PHP Notice: Undefined index: mime-type in /mnt/web213/d2/95/5228195/htdocs/mbt/wp-content/plugins/modula-best-grid-gallery/includes/public/templates/items/item.php on line 24

Here’s an example of the attachment meta. As you can see, several sizes have no mime-type defined. The item.php code raises the notice in such cases:

a:6:{s:5:"width";i:1920;s:6:"height";i:1080;s:4:"file";s:57:"2020/03/cesar-carlevarino-aragon-NL_DF0Klepc-unsplash.jpg";s:5:"sizes";a:8:{s:6:"medium";a:3:{s:4:"file";s:57:"cesar-carlevarino-aragon-NL_DF0Klepc-unsplash-300x169.jpg";s:5:"width";i:300;s:6:"height";i:169;}s:5:"large";a:3:{s:4:"file";s:58:"cesar-carlevarino-aragon-NL_DF0Klepc-unsplash-1024x576.jpg";s:5:"width";i:1024;s:6:"height";i:576;}s:9:"thumbnail";a:3:{s:4:"file";s:57:"cesar-carlevarino-aragon-NL_DF0Klepc-unsplash-150x150.jpg";s:5:"width";i:150;s:6:"height";i:150;}s:12:"medium_large";a:4:{s:4:"file";s:57:"cesar-carlevarino-aragon-NL_DF0Klepc-unsplash-768x432.jpg";s:5:"width";i:768;s:6:"height";i:432;s:9:"mime-type";s:10:"image/jpeg";}s:9:"1536x1536";a:4:{s:4:"file";s:58:"cesar-carlevarino-aragon-NL_DF0Klepc-unsplash-1536x864.jpg";s:5:"width";i:1536;s:6:"height";i:864;s:9:"mime-type";s:10:"image/jpeg";}s:9:"portfolio";a:4:{s:4:"file";s:57:"cesar-carlevarino-aragon-NL_DF0Klepc-unsplash-600x400.jpg";s:5:"width";i:600;s:6:"height";i:400;s:9:"mime-type";s:10:"image/jpeg";}s:8:"sl-small";a:4:{s:4:"file";s:57:"cesar-carlevarino-aragon-NL_DF0Klepc-unsplash-128x128.jpg";s:5:"width";i:128;s:6:"height";i:128;s:9:"mime-type";s:10:"image/jpeg";}s:8:"sl-large";a:3:{s:4:"file";s:57:"cesar-carlevarino-aragon-NL_DF0Klepc-unsplash-256x256.jpg";s:5:"width";i:256;s:6:"height";i:256;}}s:10:"image_meta";a:13:{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:14:"resized_images";a:1:{i:0;s:9:"500x99999";}}s:15:"image-converter";a:4:{s:9:"thumbnail";s:3:"IME";s:6:"medium";s:3:"IME";s:5:"large";s:3:"IME";s:8:"sl-large";s:3:"IME";}}

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Used versions

https://wordpress.org/support/topic/undefined-index-mime-type/

marcissimus commented 3 years ago

It's not clear why some images are missing the mime-type for some image_sizes. After scanning all images on my site, there's at least one image_size where the mime-type is defined but there can be several image_sizes where mime-type is undefined.

Workaround: run wp_generate_attachment_metadata( ) for all images. Afterwards, mime-type is filled for all image_sizes.