[wp-trac] [WordPress Trac] #18947: get_intermediate_image_sizes() should also contain width/height/crop values as sub array

WordPress Trac wp-trac at lists.automattic.com
Fri Oct 14 14:48:05 UTC 2011


#18947: get_intermediate_image_sizes() should also contain width/height/crop values
as sub array
-------------------------+-----------------------------
 Reporter:  F J Kaiser   |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Media        |    Version:  3.2.1
 Severity:  normal       |   Keywords:
-------------------------+-----------------------------
 Currently the function
 [http://core.trac.wordpress.org/browser/branches/3.2/wp-
 includes/media.php#L580 get_intermediate_image_sizes()] only displays a
 combined list of built-in/default & (via {{{add_image_size()}}})
 registered image size ''names''. In lot's of cases it would be pretty
 handy to also have the height, width & crop values attached as sub array
 as you can see it in {{{$GLOBALS['_wp_additional_image_sizes']}}}.

 ''I currently do not have a working dev version of wp installed, so I put
 it here as plain code:''

 Change for [http://core.trac.wordpress.org/browser/branches/3.2/wp-
 includes/media.php#L580 get_intermediate_image_sizes()]:
 {{{
 function get_intermediate_image_sizes() {
         global $_wp_additional_image_sizes;
         $image_sizes = array('thumbnail', 'medium', 'large'); // Standard
 sizes
         foreach ( $image_sizes as $size ) {
                 $image_sizes[ $size ]['width']  = intval( get_option(
 "{$size}_size_w") );
                 $image_sizes[ $size ]['height'] = intval( get_option(
 "{$size}_size_h") );
                 // Crop false per default if not set
                 $image_sizes[ $size ]['crop']   = get_option(
 "{$size}_crop" ) ? get_option( "{$size}_crop" ) : false;
         }
         if ( isset( $_wp_additional_image_sizes ) && count(
 $_wp_additional_image_sizes ) )
                 $image_sizes = array_merge( $image_sizes,
 $_wp_additional_image_sizes );

         return apply_filters( 'intermediate_image_sizes', $image_sizes );
 }
 }}}

 The only two other affected lines in core are pretty a simple fix: Use the
 {{{array_keys()}}} only:

 [http://core.trac.wordpress.org/browser/branches/3.2/wp-
 admin/includes/image.php#L106 wp_generate_attachment_metadata()]
 and
 [http://core.trac.wordpress.org/browser/branches/3.2/wp-
 includes/post.php#L3824 wp_delete_attachment()]:
 {{{
 foreach ( array_keys( get_intermediate_image_sizes() ) as $s ) {
 }}}

 I'm not really shure how the {{{crop}}} works, so this could maybe add
 additional DB calls if the option wasn't set - currently I only see
 {{{thumbnail_crop}}} added to the autoloaded options.

 ''The links are to the 3.2 branch of the repo.''

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/18947>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list