wp_get_attachment_image_url()WP 4.4.0

Get the URL of an image attachment.

1 time — 0.002972 sec (very slow) | 50000 times — 10.29 sec (slow) | PHP 7.1.5, WP 4.8.1

No Hooks.


String|false. Attachment URL or false if no image is available. If $size does not match any registered image size, the original image URL will be returned.


wp_get_attachment_image_url( $attachment_id, $size, $icon );
$attachment_id(int) (required)
Image attachment ID.
Image size. Accepts any registered image size name, or an array of width and height values in pixels (in that order).
Default: 'thumbnail'
Whether the image should be treated as an icon.
Default: false


Since 4.4.0 Introduced.

Code of wp_get_attachment_image_url() WP 5.9.3

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;