[wp-trac] [WordPress Trac] #48485: Custom image size not generated if identical to original size

WordPress Trac noreply at wordpress.org
Sun Nov 3 09:31:22 UTC 2019


#48485: Custom image size not generated if identical to original size
-------------------------------------------+-----------------------------
 Reporter:  brampeerlings                  |      Owner:  (none)
     Type:  defect (bug)                   |     Status:  new
 Priority:  normal                         |  Milestone:  Awaiting Review
Component:  Media                          |    Version:  5.2.4
 Severity:  minor                          |   Keywords:  2nd-opinion
  Focuses:  accessibility, administration  |
-------------------------------------------+-----------------------------
 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
 <?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' );

 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/48485>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list