Definition:
function wp_get_attachment_image_src($attachment_id, $size='thumbnail', $icon = false) {}
Retrieve an image to represent an attachment.
A mime icon for files, thumbnail or intermediate size for images.
Parameters
- int $attachment_id: Image attachment ID.
- string $size: Optional, default is ‘thumbnail’.
- bool $icon: Optional, default is false. Whether it is an icon.
Return values
returns:Returns an array (url, width, height), or false, if no image is available.
Defined filters
- icon_dir
apply_filters( 'icon_dir', ABSPATH . WPINC . '/images/crystal' )
Source code
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;
}
3683

February 12, 2011 


No comments yet... Be the first to leave a reply!