clarifynl / responsive-pics

Wordpress plugin that enables theme authors to automatically resize images in responsive layouts
https://responsive.pics
Other
77 stars 5 forks source link

Undefined array key "mimetype" #48

Closed mrmadhat closed 1 year ago

mrmadhat commented 1 year ago

Describe the bug An error occurs when an image is deleted from the media library but still remains as a field used for selection.

To Reproduce Steps to reproduce the behavior:

  1. Create an ACF field called image and select an image for the field
  2. Go to the media library and delete the image that has been added to the field
  3. Visit front-end where the image is being output by responsive pic
  4. See error Undefined array key "mimetype"

Expected behavior When the image has been deleted from the media library and as a result doesn't have a valid mimetype the site should still work. I also think it would be good to put a comment in the html that lets the dev know why the image isn't being output.

I think making use of wp_attachment_is_image could be part of the solution but haven't had chance to dig into the code so would need to be confirmed.

Screenshots

image

Software (please complete the following information):

Twansparant commented 1 year ago

Hi @mrmadhat, thanks for this!

I was able to reproduce this for the ResponsivePics::get_picture calls only when $intrinsic is true. I applied a fix on version 1.7.3 I just released. Could you verify this is working correctly now?

In development you should see an error message now instead:

<pre class="responsive-pics-error"><h6>ResponsivePics errors</h6><ul><li>url does not exist for id {image_id}</li></ul></pre>