Gets the URL of an image attachment.
Parameters
$attachment_id
intrequired- Image attachment ID.
$size
string|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'
$icon
booloptional- Whether the image should be treated as an icon.
Default:
false
Source
/**
* Gets the URL of an image attachment.
*
* @since 4.4.0
Changelog
Version | Description |
---|---|
4.4.0 | Introduced. |
For whoever, like me, is looking for the standard sizes, here they are:
thumbnail
= Thumbnail (default 150px x 150px max)medium
= Medium resolution (default 300px x 300px max)large
= Large resolution (default 1024px x 1024px max)full
= Full resolution (original size uploaded)Now let display somewhere:
Add this snippet to the head section in header.php to preload the attachment image on every page/post.