[wp-trac] [WordPress Trac] #64499: Undefined array key "file" in wp-includes/media.php
WordPress Trac
noreply at wordpress.org
Tue Jan 13 15:13:50 UTC 2026
#64499: Undefined array key "file" in wp-includes/media.php
--------------------------+------------------------------
Reporter: djsuperfive | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Media | Version: 6.9
Severity: blocker | Resolution:
Keywords: needs-patch | Focuses:
--------------------------+------------------------------
Description changed by sabernhardt:
Old description:
> Hi,
>
> I have this error emitted by wp-includes/media.php
>
> ErrorException thrown with message "Undefined array key "file""
>
> Stacktrace:
> #16 ErrorException in /var/www/html/htdocs/cms/wp-includes/media.php:1789
> #15 Themosis\Core\Bootstrap\ExceptionHandler:handleError in
> /var/www/html/htdocs/cms/wp-includes/media.php:1789
> #14 wp_image_add_srcset_and_sizes in /var/www/html/htdocs/cms/wp-
> includes/media.php:2342
> #13 wp_img_tag_add_srcset_and_sizes_attr in /var/www/html/htdocs/cms/wp-
> includes/media.php:1954
> #12 wp_filter_content_tags in /var/www/html/htdocs/cms/wp-includes/class-
> wp-hook.php:341
> #11 WP_Hook:apply_filters in /var/www/html/htdocs/cms/wp-
> includes/plugin.php:205
> #10 apply_filters in /var/www/html/htdocs/cms/wp-includes/blocks/post-
> content.php:50
> #9 render_block_core_post_content in /var/www/html/htdocs/cms/wp-includes
> /class-wp-block.php:599
> #8 WP_Block:render in /var/www/html/htdocs/cms/wp-includes/class-wp-
> block.php:579
> #7 WP_Block:render in /var/www/html/htdocs/cms/wp-includes/class-wp-
> block.php:579
> #6 WP_Block:render in /var/www/html/htdocs/cms/wp-
> includes/blocks.php:2383
> #5 render_block in /var/www/html/htdocs/cms/wp-includes/blocks.php:2466
> #4 do_blocks in /var/www/html/htdocs/cms/wp-includes/block-
> template.php:291
> #3 get_the_block_template_html in /var/www/html/htdocs/cms/wp-includes
> /template-canvas.php:12
> #2 include in /var/www/html/htdocs/cms/wp-includes/template-
> loader.php:125
> #1 require_once in /var/www/html/htdocs/cms/wp-blog-header.php:19
> #0 require in /var/www/html/htdocs/index.php:11
>
> I dumped the $image_media variable used in media.php:1789, and here's
> what I have:
>
> {{{
> array(6) {
> ["dominant_color"]=> string(6) "846453"
> ["has_transparency"]=> bool(false)
> ["sources"]=> array(1) {
> ["image/webp"]=> array(2) {
> ["file"]=> string(80) "royaumont_concert-dichotomia-tactus-carmen-
> kleyken-carolina-santiago-scaled.webp"
> ["filesize"]=> int(228474)
> }
> }
> ["width"]=> int(2560)
> ["height"]=> int(1920)
> ["sizes"]=> array(1) {
> ["mosaic-carre"]=> array(5) {
> ["file"]=> string(88) "royaumont_concert-dichotomia-tactus-carmen-
> kleyken-carolina-santiago-scaled-405x405.webp"
> ["width"]=> int(405)
> ["height"]=> int(405)
> ["mime-type"]=> string(10) "image/webp"
> ["cpt_last_cropping_data"]=> array(5) {
> ["version"]=> int(2)
> ["x"]=> int(449)
> ["y"]=> int(0)
> ["x2"]=> int(2560)
> ["y2"]=> int(1920)
> }
> }
> }
> }
> }}}
>
> Indeed there is no file key in the array.
> In installed the Performance Lab plugin and its Modern Formats module to
> convert jpg images to webp.
> I tried without any plugins and with the twentytwentyfive theme, same
> error.
New description:
Hi,
I have this error emitted by `wp-includes/media.php`
{{{
ErrorException thrown with message "Undefined array key "file""
Stacktrace:
#16 ErrorException in /.../cms/wp-includes/media.php:1789
#15 Themosis\Core\Bootstrap\ExceptionHandler:handleError in /.../cms/wp-
includes/media.php:1789
#14 wp_image_add_srcset_and_sizes in /.../cms/wp-includes/media.php:2342
#13 wp_img_tag_add_srcset_and_sizes_attr in /.../cms/wp-
includes/media.php:1954
#12 wp_filter_content_tags in /.../cms/wp-includes/class-wp-hook.php:341
#11 WP_Hook:apply_filters in /.../cms/wp-includes/plugin.php:205
#10 apply_filters in /.../cms/wp-includes/blocks/post-content.php:50
#9 render_block_core_post_content in /.../cms/wp-includes/class-wp-
block.php:599
#8 WP_Block:render in /.../cms/wp-includes/class-wp-block.php:579
#7 WP_Block:render in /.../cms/wp-includes/class-wp-block.php:579
#6 WP_Block:render in /.../cms/wp-includes/blocks.php:2383
#5 render_block in /.../cms/wp-includes/blocks.php:2466
#4 do_blocks in /.../cms/wp-includes/block-template.php:291
#3 get_the_block_template_html in /.../cms/wp-includes/template-
canvas.php:12
#2 include in /.../cms/wp-includes/template-loader.php:125
#1 require_once in /.../cms/wp-blog-header.php:19
#0 require in /.../index.php:11
}}}
I dumped the `$image_media` variable used in media.php:1789, and here's
what I have:
{{{
array(6) {
["dominant_color"]=> string(6) "846453"
["has_transparency"]=> bool(false)
["sources"]=> array(1) {
["image/webp"]=> array(2) {
["file"]=> string(80) "royaumont_concert-dichotomia-tactus-carmen-
kleyken-carolina-santiago-scaled.webp"
["filesize"]=> int(228474)
}
}
["width"]=> int(2560)
["height"]=> int(1920)
["sizes"]=> array(1) {
["mosaic-carre"]=> array(5) {
["file"]=> string(88) "royaumont_concert-dichotomia-tactus-carmen-
kleyken-carolina-santiago-scaled-405x405.webp"
["width"]=> int(405)
["height"]=> int(405)
["mime-type"]=> string(10) "image/webp"
["cpt_last_cropping_data"]=> array(5) {
["version"]=> int(2)
["x"]=> int(449)
["y"]=> int(0)
["x2"]=> int(2560)
["y2"]=> int(1920)
}
}
}
}
}}}
Indeed there is no file key in the array.
I installed the Performance Lab plugin and its Modern Formats module to
convert jpg images to webp.
I tried without any plugins and with the twentytwentyfive theme, same
error.
--
--
Ticket URL: <https://core.trac.wordpress.org/ticket/64499#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list