[wp-trac] [WordPress Trac] #51780: Add ability to easily get path to sized images (such as parameter to get_attached_file() or wp_get_attachment_thumb_file())

WordPress Trac noreply at wordpress.org
Fri Feb 24 21:37:41 UTC 2023


#51780: Add ability to easily get path to sized images (such as parameter to
get_attached_file() or wp_get_attachment_thumb_file())
-------------------------------------------------+-------------------------
 Reporter:  paulschreiber                        |       Owner:  joedolson
     Type:  enhancement                          |      Status:  reopened
 Priority:  normal                               |   Milestone:  6.2
Component:  Media                                |     Version:  5.5.3
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch has-unit-tests 2nd-        |     Focuses:
  opinion changes-requested                      |
-------------------------------------------------+-------------------------

Comment (by paulschreiber):

 >On top of that the ticket description mentions that an existing function
 can be used for this, but doesn't mention why the proposed functionality
 would be useful. My guess is it would be a very minor convenience for
 maybe a few plugins that may meed the path to an image sub-size. Not sure
 this is a good reason to add this to core.

 I gave context in the original ticket. Right now, everyone has to write 3
 lines of code + null checks (so ≥12 lines). This greatly increases the
 possibility of error. Having core do this for you is very helpful, and
 core is more likely to get it right than random theme/plugin authors.

 You can see the theme where this was used:
 https://github.com/CTCL/election-
 websites/blob/e5fc55dd651fb73d13114262b2dd60e8a095a91c/includes/class-
 helpers.php#L321-L356

 Much of this was required because WPCOM behaves differently than
 everywhere else, which I detail in the comments in that source code.

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


More information about the wp-trac mailing list