WordPress.org

Ready to get started?Download WordPress

Codex

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

Function Reference/get image tag

Description

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.

Usage

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

Parameters

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

Return Values

(string) 
HTML IMG element for given image attachment

Change Log

Since: 2.5

Source File

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