Make WordPress Core

Opened 2 years ago

Last modified 2 years ago

#48485 new defect (bug)

Custom image size not generated if identical to original size

Reported by: brampeerlings Owned by:
Milestone: Awaiting Review Priority: normal
Severity: minor Version: 5.2.4
Component: Media Keywords: 2nd-opinion
Focuses: administration Cc:


When defining a custom image size using add_image_size and uploading an image that has exactly the same dimensions of that image size, the new image size is not added. This also means that -- when adding the newly defined image size -- to the Insert Media screen using the image_size_names_choose-filter, the custom image size does not appear in the dropdown menu.

Even though I can understand why this happens from a server load / storage point of view, I feel the unexpected behaviour (to end users) is a bigger problem. An even prettier fix would be to detect the custom image size is identical to the original size and map the custom image size URL to the original file URL (e.g. through a symbolic link).

if ( function_exists( 'add_image_size' ) ) {
    add_image_size( 'project-photo', 1920, 1080, false);

function custom_media_sizes( $sizes ) {
    return array_merge( $sizes, array(
        'project-photo' => __( 'Project-foto' ),
    ) );
add_filter( 'image_size_names_choose', 'custom_media_sizes' );

Change History (2)

This ticket was mentioned in Slack in #accessibility by afercia. View the logs.

2 years ago

#2 @afercia
2 years ago

  • Focuses accessibility removed

Discussed during today's accessibility bug-scrub: not sure this issue is related to accessibility, removing the accessibility focus for now.

Note: See TracTickets for help on using tickets.