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
Source
* @param string|int[] $size Requested image size. Can be any registered image size name, or
* an array of width and height values in pixels (in that order).
* @param bool $icon Whether the image should be treated as an icon.
* @param string[] $attr Array of attribute values for the image markup, keyed by attribute name.
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.