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

WordPress Trac noreply at wordpress.org
Fri Jul 31 19:07:33 UTC 2015


#18947: get_intermediate_image_sizes() should also contain width/height/crop values
as sub array
-------------------------+-----------------------------
 Reporter:  F J Kaiser   |       Owner:
     Type:  enhancement  |      Status:  assigned
 Priority:  normal       |   Milestone:  Future Release
Component:  Media        |     Version:  3.2.1
 Severity:  normal       |  Resolution:
 Keywords:  needs-patch  |     Focuses:
-------------------------+-----------------------------

Comment (by johnnyb):

 I came here after finding that something like get_image_size( 'sizename'
 ); or get_images_sizes() doesn't exist.

 '''Use case:'''
 I want to add a `srcset` attribute to a post thumbnail that provides 2x
 and 3x options for the image, (assuming it's a fixed pixel width). The
 `wp_get_attachment_iamges_attributes` filter gets the arguments `$attr`,
 `$attachment`, and `$size`, the last of which can be either a width/height
 array or a named size. In order to generate URLs for the 2x and 3x image
 sizes I need to know what size I'm dealing with, and if `$size` is
 something like 'homepage_hero_poster' that doesn't tell me much.

 Naming:
 We've already got `add_image_size()`, `has_image_size()`, and
 `remove_image_size()` as well as `get_intermediate_image_sizes()` (all in
 media.php). Adding `get_image_size( $sizename )` would have name parity
 with the first 3 functions mentioned above, and would let someone easily
 implement a `get_image_sizes()` function themselves. Alternately we could
 implement both.

 THere's already decent-looking code for a `get_image_sizes()` function on
 the [Codex page for
 `get_intermediate_image_sizes()`](https://codex.wordpress.org/Function_Reference/get_intermediate_image_sizes).

--
Ticket URL: <https://core.trac.wordpress.org/ticket/18947#comment:22>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list