Switch language

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




wp_get_attachment_image_src [ WordPress Function ]

wp_get_attachment_image_src ( $attachment_id, $size = 'thumbnail', $icon = false )
Parameters:
  • (int) $attachment_id Image attachment ID.
  • (string) $size Optional, default is 'thumbnail'.
  • (bool) $icon Optional, default is false. Whether it is an icon.
Returns:
  • (bool|array) Returns an array (url, width, height), or false, if no image is available.
Defined at:



Retrieve an image to represent an attachment.

A mime icon for files, thumbnail or intermediate size for images.

Source


<?php
function wp_get_attachment_image_src($attachment_id$size='thumbnail'$icon false) {

    
// get a thumbnail or intermediate image if there is one
    
if ( $image image_downsize($attachment_id$size) )
        return 
$image;

    
$src false;

    if ( 
$icon && $src wp_mime_type_icon($attachment_id) ) {
        
$icon_dir apply_filters'icon_dir'ABSPATH WPINC '/images/crystal' );
        
$src_file $icon_dir '/' wp_basename($src);
        @list(
$width$height) = getimagesize($src_file);
    }
    if ( 
$src && $width && $height )
        return array( 
$src$width$height );
    return 
false;
}
?>

Examples [ wp-snippets.com ]

Top Google zoekresultaten

Meer ...

0 User Note(s)

Nog geen één. Wees de eerste!

Nieuw toevoegen ...



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