[wp-trac] [WordPress Trac] #34817: Add a new image size detection function

WordPress Trac noreply at wordpress.org
Sun Nov 29 23:15:30 UTC 2015


#34817: Add a new image size detection function
------------------------------+-----------------------------
 Reporter:  simonrcodrington  |      Owner:
     Type:  enhancement       |     Status:  new
 Priority:  normal            |  Milestone:  Awaiting Review
Component:  Media             |    Version:  4.3.1
 Severity:  normal            |   Keywords:
  Focuses:                    |
------------------------------+-----------------------------
 Hi there,

 Currently if you need to see if a custom image size exists for an image
 you need to call `get_image_sizes` and pass in your image id. This returns
 either the the applicable information for that image size or false.

 I think a better approach would be to have a function such as
 `images_size_exists()` which just detects if that size exists for a given
 image id and returns true or false.

 When using `wp_get_attachment_image_src` for example, you pass in your
 desired size, e.g 'large'. If the size you passed in doesn't exist for the
 image it will choose an applicable similar image such as the 'full' size.
 If there was a function like `images_size_exists()` it would let you
 conditionally target based on if sizes exist.

 I'm pretty keen on potentially adding this as a feature if it's not being
 worked on by anyone else?

 Thoughts guys?

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


More information about the wp-trac mailing list