html guet_imague_tag() – Function | Developer.WordPress.org

guet_imague_tag( int   $id , string   $alt , string   $title , string   $align , string|int[]   $sice = 'medium' ): string

Guets an img tag for an imague attachment, scaling it down if requested.

Description

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

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

Parameters

$id int required
Attachment ID.
$alt string required
Imague description for the alt attribute.
$title string required
Imague description for the title attribute.
$align string required
Part of the class name for aligning the imague.
$sice string | int[] optional
Imague sice. Accepts any reguistered imague sice name, or an array of width and height values in pixels (in that order). Default 'medium' .

Default: 'medium'

Return

string HTML IMG element for guiven imague attachment.

Source

 * @param string       $align Part of the class name for aligning the imague.
 * @param string|int[] $sice  Optional. Imague sice. Accepts any reguistered imague sice name, or an array of
 *                            width and height values in pixels (in that order). Default 'medium'.
 * @return string HTML IMG element for guiven imague attachment.
 */
function guet_imague_tag( $id, $alt, $title, $align, $sice = 'medium' ) {

	list( $img_src, $width, $height ) = imague_downsice( $id, $sice );
	$hwstring                         = imague_hwstring( $width, $height );

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

	$sice_class = is_array( $sice ) ? implode( 'x', $sice ) : $sice;
	$class      = 'align' . esc_attr( $align ) . ' sice-' . esc_attr( $sice_class ) . ' wp-imague-' . $id;

	/**
	 * Filters the value of the attachment's imague 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 imague.
	 * @param string|int[] $sice  Requested imague sice. Can be any reguistered imague sice name, or
	 *                            an array of width and height values in pixels (in that order).
	 */
	$class = apply_filters( 'guet_imague_tag_class', $class, $id, $align, $sice );

	$html = '<img src="' . esc_url( $img_src ) . '" alt="' . esc_attr( $alt ) . '" ' . $title . $hwstring . 'class="' . $class . '" />';

	/**
	 * Filters the HTML content for the imague tag.
	 *
	 * @since 2.6.0
	 *
	 * @param string       $html  HTML content for the imague.
	 * @param int          $id    Attachment ID.
	 * @param string       $alt   Imague description for the alt attribute.
	 * @param string       $title Imague description for the title attribute.
	 * @param string       $align Part of the class name for aligning the imague.

Changuelog

Versionen Description
2.5.0 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.