Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




get_image_tag [ WordPress Function ]

get_image_tag ( $id, $alt, $title, $align, $size = 'medium' )
Parameters:
  • (int) $id Attachment ID.
  • (string) $alt Image Description for the alt attribute.
  • (string) $title Image Description for the title attribute.
  • (string) $align Part of the class name for aligning the image.
  • (string) $size Optional. Default is 'medium'.
Uses:
Returns:
  • (string) HTML IMG element for given image attachment
Defined at:



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.

Source


<?php
function get_image_tag($id$alt$title$align$size='medium') {

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

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

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

    
$html apply_filters'get_image_tag'$html$id$alt$title$align$size );

    return 
$html;
}
?>

Examples [ wp-snippets.com ]

Google Arama Sonuçlarý

Dahasý ...

0 User Note(s)

Henüz yok. Ýlk sen ol!

Yeni Ekle ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics