wp_get_attachment_thumb_url()
Retrieve URL for an attachment thumbnail.
Uses: image_downsize()
1 time — 0.001119 sec (very slow) | 50000 times — 6.09 sec (fast) | PHP 7.0.8, WP 4.6
Hooks from the function
Return
String|false
. Thumbnail URL on success, false on failure.
Usage
wp_get_attachment_thumb_url( $post_id );
- $post_id(int)
- Attachment ID.
Default: ID of the global $post
Examples
#1 Get a link to the thumbnail size of the image
Let's say we have an image with ID 7412 in the media library and we need to get a URL to its thumbnail (the smallest size):
$thumburl = wp_get_attachment_thumb_url( 7412 ); echo $thumburl; //> http://example.com/wp-content/uploads/2016/09/Upravlenie-setyu-80x80.png
Changelog
Since 2.1.0 | Introduced. |
Since 6.1.0 | Changed to use wp_get_attachment_image_url(). |