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.


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


(string) HTML IMG element for given image attachment


function get_image_tag($id, $alt, $title, $align, $size='medium') {

	list( $img_src, $width, $height ) = image_downsize($id, $size);
	$hwstring = image_hwstring($width, $height);

	$title = $title ? 'title="' . esc_attr( $title ) . '" ' : '';

	$class = 'align' . esc_attr($align) .' size-' . esc_attr($size) . ' wp-image-' . $id;

	 * Filter the value of the attachment's image tag class attribute.
	 * @since 2.6.0
	 * @param string $class CSS class name or space-separated list of classes.
	 * @param int    $id    Attachment ID.
	 * @param string $align Part of the class name for aligning the image.
	 * @param string $size  Optional. Default is 'medium'.
	$class = apply_filters( 'get_image_tag_class', $class, $id, $align, $size );
19 more lines...
WP Trac GitHub

Link here