get_attachment_icon_src

Retrieve icon URL and Path.

Description

(array) get_attachment_icon_src( (int) $id = 0, (bool) $fullsize = false ); 

Returns (array)

Icon URL and full path to file, respectively.

Parameters (2)

0. $id — Optional. (int)
Post ID.
1. $fullsize — Optional. (bool) => false
Optional, default to false. Whether to have full image.

Usage

  1. if ( !function_exists( 'get_attachment_icon_src' ) ) { 
  2. require_once ABSPATH . WPINC . '/deprecated.php'; 
  3.  
  4. // Optional. Post ID. 
  5. $id = -1; 
  6.  
  7. // Optional, default to false. Whether to have full image. 
  8. $fullsize = false; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = get_attachment_icon_src($id, $fullsize); 
  12.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/deprecated.php  
  1. function get_attachment_icon_src( $id = 0, $fullsize = false ) { 
  2. _deprecated_function( __FUNCTION__, '2.5.0', 'wp_get_attachment_image_src()' ); 
  3. $id = (int) $id; 
  4. if ( !$post = get_post($id) ) 
  5. return false; 
  6.  
  7. $file = get_attached_file( $post->ID ); 
  8.  
  9. if ( !$fullsize && $src = wp_get_attachment_thumb_url( $post->ID ) ) { 
  10. // We have a thumbnail desired, specified and existing 
  11.  
  12. $src_file = basename($src); 
  13. } elseif ( wp_attachment_is_image( $post->ID ) ) { 
  14. // We have an image without a thumbnail 
  15.  
  16. $src = wp_get_attachment_url( $post->ID ); 
  17. $src_file = & $file; 
  18. } elseif ( $src = wp_mime_type_icon( $post->ID ) ) { 
  19. // No thumb, no image. We'll look for a mime-related icon instead. 
  20.  
  21. $icon_dir = apply_filters( 'icon_dir', get_template_directory() . '/images' ); 
  22. $src_file = $icon_dir . '/' . basename($src); 
  23.  
  24. if ( !isset($src) || !$src ) 
  25. return false; 
  26.  
  27. return array($src, $src_file);