wp_get_attachment_image_url() WP 1.0
Get the URL of an image attachment.
Works based on: wp_get_attachment_image_src()
Basis of: get_the_post_thumbnail_url()
1 time = 0.002972s = very slow | 50000 times = 10.29s = slow | PHP 7.1.5, WP 4.8.1
No Hooks.
Return
String/false. Attachment URL or false if no image is available.
Usage
wp_get_attachment_image_url( $attachment_id, $size, $icon );
- $attachment_id(int) (required)
- Image attachment ID.
- $size(string/int[])
- Image size. Accepts any registered image size name, or an array of width and height values in pixels (in that order).
Default: 'thumbnail' - $icon(true/false)
- Whether the image should be treated as an icon.
Default: false
Changelog
Since 4.4.0 | Introduced. |
Code of wp_get_attachment_image_url() wp get attachment image url WP 5.6
function wp_get_attachment_image_url( $attachment_id, $size = 'thumbnail', $icon = false ) {
$image = wp_get_attachment_image_src( $attachment_id, $size, $icon );
return isset( $image['0'] ) ? $image['0'] : false;
}Related Functions
From tag: Thumbnail (images)
- add_image_size()
- delete_post_thumbnail()
- get_intermediate_image_sizes()
- get_post_thumbnail_id()
- get_the_post_thumbnail()
- get_the_post_thumbnail_caption()
- get_the_post_thumbnail_url()
More from tag: Link (URL)
- admin_url()
- attachment_url_to_postid()
- build_query()
- comment_link()
- content_url()
- get_comments_link()
- get_comments_pagenum_link()
- get_edit_post_link()
- get_edit_term_link()
- get_home_url()
- get_next_comments_link()
- get_post_embed_url()