Make WordPress Core

Opened 3 weeks ago

Closed 3 weeks ago

Last modified 9 days ago

#65913 closed defect (bug) (duplicate)

Fix trailing space in 'width ' key in WP_Site_Icon::additional_sizes()

Reported by: analogstudio Owned by:
Priority: normal Milestone:
Component: Media Version:
Severity: minor Keywords:
Cc: Focuses:

Description

There is a typo in the array key returned by WP_Site_Icon::additional_sizes().

Problem

In wp-admin/includes/class-wp-site-icon.php:L174, a trailing space is accidentally included in the 'width ' key:

<?php
$only_crop_sizes[ 'site_icon-' .$size ] = array(
  'width ' => $size, // Trailing space in key
  'height' => $size,
  'crop'   => true,
);

While WordPress core itself does not directly reference $datawidth from this specific return value, plugins or third-party developers inspecting image sizes via the intermediate_image_sizes_advanced filter or accessing this array will encounter null or undefined index errors when attempting to read $sizewidth.

Proposed Fix

Remove the trailing space from 'width ' so it becomes 'width'.

<?php
$only_crop_sizes[ 'site_icon-' .$size ] = array(
  'width'  => $size, // Fixed key
  'height' => $size,
  'crop'   => true,
);

Change History (4)

#1 @mukesh27
3 weeks ago

  • Resolutionfixed
  • Status newclosed
  • Version 4.3

#2 @mukesh27
3 weeks ago

  • Resolution fixedduplicate

Duplicate of #65345.

#3 @analogstudio
3 weeks ago

Thanks for catching this and pointing out the existing ticket! I'll follow up on #65345.

This ticket was mentioned in Slack in #meta by jorbin. View the logs.


9 days ago

Note: See TracTickets for help on using tickets.