[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:01:07 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                      |
-------------------------------------------------+-------------------------
Changes (by azaozz):

 * keywords:  has-patch has-unit-tests 2nd-opinion => has-patch has-unit-
     tests 2nd-opinion changes-requested


Comment:

 Replying to [comment:25 joedolson]:
 > it makes sense to use the same function to fetch variants of a file

 The functionality of `get_attached_file()` is to "get the attached file",
 i.e. to get the path to the file that was uploaded by the user and is now
 "attached" to an attachment post.

 > The function is to get a file, not to get an attachment

 Exactly, it is to get the path to **the file** attached to a particular
 attachment post.

 > fetch any file managed in the media library

 I think I understand where you're coming from but don't think it is a good
 idea to extend a function that has to perform one simple task for all
 files that have been uploaded by the users and make it work differently
 for different file types. In addition I don't think this is a good
 functionality to have in core anyway. It is not used anywhere in core, and
 there hasn't been a need for it for so many years.

 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 code.

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


More information about the wp-trac mailing list