Ready to get started?Download WordPress


Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/get image tag


An <img src /> tag for an image attachment, scaling it down if requested.

The filter 'get_image_tag_class' 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.


<?php get_image_tag$id$alt$title$align$size ); ?>


(int) (required) Attachment ID.
Default: None
(string) (required) Image Description for the alt attribute.
Default: None
(string) (required) Image Description for the title attribute.
Default: None
(string) (required) Part of the class name for aligning the image.
Default: None
(string) (optional) Optional. Default is 'medium'.
Default: medium

Return Values

HTML IMG element for given image attachment

Change Log

Since: 2.5

Source File

get_image_tag() is located in wp-includes/media.php