Make WordPress Core

Opened 4 weeks ago

Last modified 2 weeks ago

#48324 new defect (bug)

Undefined index: full in/wp-includes/media.php on line 214

Reported by: Mte90 Owned by:
Milestone: 5.3.1 Priority: normal
Severity: normal Version: 4.7
Component: Media Keywords: has-patch 2nd-opinion needs-testing
Focuses: Cc:
PR Number:


I don't know why I am getting this error but is very spammy on the log.
After a look inside the code I found the guilty line https://github.com/WordPress/WordPress/blob/5.2-branch/wp-includes/media.php#L211

if ( ! $is_image ) {
	if ( ! empty( $meta['sizes'] ) ) {
		$img_url          = str_replace( $img_url_basename, $meta['sizes']['full']['file'], $img_url );

The fix is quite simple:

if ( ! $is_image ) {
	if ( ! empty( $meta['sizes'] ) && isset( $meta['sizes']['full'] ) ) {
		$img_url          = str_replace( $img_url_basename, $meta['sizes']['full']['file'], $img_url );

From the code seems that doesn't found an attachment size, maybe because I am using the new live_url feature of VVV (https://github.com/Varying-Vagrant-Vagrants/custom-site-template) that let o redirect by nginx the image using a remote, so is not required to have a copy of the files.

Attachments (2)

48324.diff (726 bytes) - added by Mte90 4 weeks ago.
fix as proposed in the ticket
48324.1.diff (682 bytes) - added by Hareesh Pillai 5 days ago.
Patch updated as per the latest comment

Download all attachments as: .zip

Change History (6)

4 weeks ago

fix as proposed in the ticket

#1 @Mte90
4 weeks ago

  • Keywords has-patch 2nd-opinion needs-testing added
  • Version set to 5.2.3

#2 @desrosj
4 weeks ago

  • Milestone changed from Awaiting Review to 5.3.1
  • Version changed from 5.2.3 to 4.7

Looks like this was introduced in [38949] (see #31050).

I'm adding this to 5.3.1 as this is not a regression. But I'm wondering if the changes related to generating images has caused this notice to become more common.

This ticket was mentioned in Slack in #core-media by mike. View the logs.

4 weeks ago

#4 @jrf
2 weeks ago

Had a quick look. IMHO a simpler fix - and just as effective - would be to replace the ! empty( $meta['sizes'] ) with ! empty( $meta['sizes']['full'] ).

Side-note: I do wonder how an image can exist without a full sized version ? Sratch that, just noticed this only applies to non-images.

Last edited 2 weeks ago by jrf (previous) (diff)

@Hareesh Pillai
5 days ago

Patch updated as per the latest comment

Note: See TracTickets for help on using tickets.