W3cubDocs

/WordPress

wp_get_attachment_image_url( int $attachment_id, string|int[] $size = ‘thumbnail’, bool $icon = false ): string|false

Gets the URL of an image attachment.

Parameters

$attachment_idintrequired
Image attachment ID.
$sizestring|int[]optional
Image size. Accepts any registered image size name, or an array of width and height values in pixels (in that order). Default 'thumbnail'.

Default:'thumbnail'

$iconbooloptional
Whether the image should be treated as an icon.

Default:false

Return

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.

Source

/**
 * Gets the URL of an image attachment.
 *
 * @since 4.4.0

Changelog

Version Description
4.4.0 Introduced.

© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_get_attachment_image_url