WPDev.one
Core Function
View Source on Trac ↗

wp_get_attachment_image()

wp_get_attachment_image( mixed $attachment_id, mixed $size = 'thumbnail', mixed $icon = false, mixed $attr = '' )

Gets an HTML img element representing an image attachment.

Parameters 3 required

Name / Type Description
$attachment_id
int

Image attachment ID.

Required
mixed

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

Required
$icon
bool

Optional. Whether the image should be treated as an icon. Default false.

mixed

(string | array) $attr { Optional. Attributes for the image markup.

Required

Return Value

(string)
HTML img element or empty string on failure.

Function Information

Since Version
2.5.0
Source File
wp-includes/media.php
Advertisement