Opened 11 years ago
Last modified 2 years ago
#33959 new enhancement
Improve wp_get_attachment_thumb_file
| Reported by: | Rahe | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Media | Version: | 4.4 |
| Severity: | normal | Keywords: | has-patch needs-refresh needs-unit-tests |
| Cc: | Focuses: |
Description
Since we can retrieve an image thumbnail url it will be nice if we can get the path of this thumbnail too.
Here is a patch allowing this. And improvements for the first parameter allowing it to be a WP_Post object.
Attachments (2)
Change History (8)
#1
@
11 years ago
- Component Post Thumbnails → Media
- Keywords has-patch needs-refresh needs-unit-tests added
#2
@
11 years ago
Here one another patch with the suggested modifications.
I don't know how to create the unit test for it, but i'd like to do so :)
#3
follow-ups:
↓ 5
↓ 6
@
11 years ago
Just had another look at this.
First of all, it seems like wp_get_attachment_thumb_file doesn't even work. $imagedata['thumb'] should probably be $imagedata['sizes']['thumbnail']['file']. See also this bug report from 3 years ago.
Second, doesn't image_get_intermediate_size already do what you want to achieve?
This ticket was mentioned in Slack in #core by swissspidy. View the logs.
11 years ago
#5
in reply to: ↑ 3
@
11 years ago
Replying to swissspidy:
First of all, it seems like
wp_get_attachment_thumb_filedoesn't even work.$imagedata['thumb']should probably be$imagedata['sizes']['thumbnail']['file'].
See #17262.
#6
in reply to: ↑ 3
@
11 years ago
Replying to swissspidy:
Second, doesn't
image_get_intermediate_sizealready do what you want to achieve?
The documentation for image_get_intermediate_size isn't clear (see: #34124), but you're correct that it does return both the path and URL, as long as you are passing a valid intermediate size name (e.g. 'medium') as the second parameter and not an array of height/width values.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
I'd rather introduce a new
wp_get_attachment_file( $post, $size )function.wp_get_attachment_thumb_file()could then simply be a wrapper forwp_get_attachment_file( $post = null, $size = 'thumb' )