[wp-trac] [WordPress Trac] #58535: Undefined array key "file" in function wp_calculate_image_srcset()
WordPress Trac
noreply at wordpress.org
Tue Oct 22 18:17:49 UTC 2024
#58535: Undefined array key "file" in function wp_calculate_image_srcset()
--------------------------+-----------------------------
Reporter: martinjhenne | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Future Release
Component: General | Version:
Severity: normal | Resolution:
Keywords: | Focuses:
--------------------------+-----------------------------
Comment (by jeremyfelt):
>Note that I haven't actually figured out how a "normal" user would get
the image URL to use, but at least one of ours has, and that's how I was
able to track this down
I ran into this today as well and was finally able to figure out how to
reproduce it.
1. Add a new image block
2. Choose "Media Library"
3. See the PDF I previously added is not available, select the "Upload"
tab
4. Upload the PDF
5. Confirm by clicking "Select"
Note that if you attempt to upload without going through the media
library, the PDF will not be allowed in this context.
At this point, the "Large" version of the PDF, a resized JPG provided by
ImageMagick, is used as the image source. But, every time `srcset` and
`sizes` values are calculated, the `file` key, which does not exist for
the PDF, is not available and a warning is displayed.
I'm not sure why `file` is not populated for uploaded PDF files, but
adding a bit more defensive check for a missing `file` key before
processing its value is probably the better move.
And/or... actually disabling PDF uploads through this weird workaround. :)
Related (maybe duplicate): #60480
--
Ticket URL: <https://core.trac.wordpress.org/ticket/58535#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list