Opened 16 months ago
Last modified 16 months ago
#48485 new defect (bug)
Custom image size not generated if identical to original size
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | 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' );
Discussed during today's accessibility bug-scrub: not sure this issue is related to accessibility, removing the accessibility focus for now.