get_image_tag

SummerySummery

Gets an img tag for an image attachment, scaling it down if requested.

Syntax

get_image_tag( int $id, string $alt, string $title, string $align, string|array $size = 'medium' )

DescriptionDescription

The ‘get_image_tag_class’ filter allows for changing the class name for the image without having to use regular expressions on the HTML content. The parameters are: what WordPress will use for the class, the Attachment ID, image align value, and the size the image should be.

The second filter, ‘get_image_tag’, has the HTML content, which can then be further manipulated by a plugin to change all attribute values and even HTML content.

ParametersParameters

$id

(int) (Required) Attachment ID.

$alt

(string) (Required) Image description for the alt attribute.

$title

(string) (Required) Image description for the title attribute.

$align

(string) (Required) Part of the class name for aligning the image.

$size

(string|array) (Optional) Registered image size to retrieve a tag for. Accepts any valid image size, or an array of width and height values in pixels (in that order).

Default value: 'medium'

ReturnReturn

(string) HTML IMG element for given image attachment

SourceSource

File: wp-includes/media.php


			

ChangelogChangelog

Changelog
Version Description
2.5.0 Introduced.
Scroll to Top