WordPress.org

Make WordPress Core

Opened 2 weeks ago

Last modified 3 days 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:
PR Number:

Description

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).

<?php
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.


3 days ago

#2 @afercia
3 days 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.