Make WordPress Core

Opened 4 years ago

Last modified 4 months ago

#48485 new defect (bug)

Custom image size not generated if identical to original size

Reported by: brampeerlings's profile brampeerlings Owned by:
Milestone: 6.3 Priority: normal
Severity: minor Version: 5.2.4
Component: Media Keywords: 2nd-opinion
Focuses: administration Cc:

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 (8)

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


4 years ago

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

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


6 months ago

#4 @antpb
6 months ago

  • Milestone changed from Awaiting Review to 6.2

This was mentioned in the Media component meeting and we were able to reproduce the report.

  • To reproduce add the provided snippet with the sizes attribute exactly matching an image available
  • Upload that image
  • Insert that image to a post and notice that the custom size is not available.
  • Upload any other image that is not the same size
  • Insert the second image into a post and notice the custom size _is_ available

We need to catch for the case of custom sizes matching the uploaded image and use the originally uploaded image for that custom size.

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


4 months ago

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


4 months ago

#7 @antpb
4 months ago

this is likely not to make it into the 6.2 milestone. This should move to 6.3 when possible.

#8 @sabernhardt
4 months ago

  • Milestone changed from 6.2 to 6.3
Note: See TracTickets for help on using tickets.