Title: get_attachment_icon_src
Published: April 25, 2014
Last modified: April 28, 2025

---

# get_attachment_icon_src( int $id, bool $fullsize = false ): array

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/get_attachment_icon_src/?output_format=md#description)
    - [See also](https://developer.wordpress.org/reference/functions/get_attachment_icon_src/?output_format=md#see-also)
 * [Parameters](https://developer.wordpress.org/reference/functions/get_attachment_icon_src/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/get_attachment_icon_src/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/get_attachment_icon_src/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/get_attachment_icon_src/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/get_attachment_icon_src/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/get_attachment_icon_src/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/get_attachment_icon_src/?output_format=md#wp--skip-link--target)

This function has been deprecated since 2.5.0. Use [wp_get_attachment_image_src()](https://developer.wordpress.org/reference/functions/wp_get_attachment_image_src/)
instead.

Retrieve icon URL and Path.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/get_attachment_icon_src/?output_format=md#description)󠁿

### 󠀁[See also](https://developer.wordpress.org/reference/functions/get_attachment_icon_src/?output_format=md#see-also)󠁿

 * [wp_get_attachment_image_src()](https://developer.wordpress.org/reference/functions/wp_get_attachment_image_src/)

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/get_attachment_icon_src/?output_format=md#parameters)󠁿

 `$id`intoptional

Post ID.

`$fullsize`booloptional

Whether to have full image.

Default:`false`

## 󠀁[Return](https://developer.wordpress.org/reference/functions/get_attachment_icon_src/?output_format=md#return)󠁿

 array Icon URL and full path to file, respectively.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/get_attachment_icon_src/?output_format=md#source)󠁿

    ```php
    function get_attachment_icon_src( $id = 0, $fullsize = false ) {
    	_deprecated_function( __FUNCTION__, '2.5.0', 'wp_get_attachment_image_src()' );
    	$id = (int) $id;
    	if ( !$post = get_post($id) )
    		return false;

    	$file = get_attached_file( $post->ID );

    	if ( !$fullsize && $src = wp_get_attachment_thumb_url( $post->ID ) ) {
    		// We have a thumbnail desired, specified and existing.

    		$src_file = wp_basename($src);
    	} elseif ( wp_attachment_is_image( $post->ID ) ) {
    		// We have an image without a thumbnail.

    		$src = wp_get_attachment_url( $post->ID );
    		$src_file = & $file;
    	} elseif ( $src = wp_mime_type_icon( $post->ID, '.svg' ) ) {
    		// No thumb, no image. We'll look for a mime-related icon instead.

    		/** This filter is documented in wp-includes/post.php */
    		$icon_dir = apply_filters( 'icon_dir', get_template_directory() . '/images' );
    		$src_file = $icon_dir . '/' . wp_basename($src);
    	}

    	if ( !isset($src) || !$src )
    		return false;

    	return array($src, $src_file);
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/deprecated.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/deprecated.php#L1896)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/deprecated.php#L1896-L1925)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/get_attachment_icon_src/?output_format=md#hooks)󠁿

 [apply_filters( ‘icon_dir’, string $path )](https://developer.wordpress.org/reference/hooks/icon_dir/)

Filters the icon directory path.

## 󠀁[Related](https://developer.wordpress.org/reference/functions/get_attachment_icon_src/?output_format=md#related)󠁿

| Uses | Description | 
| [get_template_directory()](https://developer.wordpress.org/reference/functions/get_template_directory/)`wp-includes/theme.php` |

Retrieves template directory path for the active theme.

  | 
| [wp_attachment_is_image()](https://developer.wordpress.org/reference/functions/wp_attachment_is_image/)`wp-includes/post.php` |

Determines whether an attachment is an image.

  | 
| [wp_mime_type_icon()](https://developer.wordpress.org/reference/functions/wp_mime_type_icon/)`wp-includes/post.php` |

Retrieves the icon for a MIME type or attachment.

  | 
| [wp_get_attachment_thumb_url()](https://developer.wordpress.org/reference/functions/wp_get_attachment_thumb_url/)`wp-includes/post.php` |

Retrieves URL for an attachment thumbnail.

  | 
| [wp_get_attachment_url()](https://developer.wordpress.org/reference/functions/wp_get_attachment_url/)`wp-includes/post.php` |

Retrieves the URL for an attachment.

  | 
| [get_attached_file()](https://developer.wordpress.org/reference/functions/get_attached_file/)`wp-includes/post.php` |

Retrieves attached file path based on attachment ID.

  | 
| [wp_basename()](https://developer.wordpress.org/reference/functions/wp_basename/)`wp-includes/formatting.php` |

i18n-friendly version of basename().

  | 
| [_deprecated_function()](https://developer.wordpress.org/reference/functions/_deprecated_function/)`wp-includes/functions.php` |

Marks a function as deprecated and inform when it has been used.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  | 
| [get_post()](https://developer.wordpress.org/reference/functions/get_post/)`wp-includes/post.php` |

Retrieves post data given a post ID or post object.

  |

[Show 5 more](https://developer.wordpress.org/reference/functions/get_attachment_icon_src/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/get_attachment_icon_src/?output_format=md#)

| Used by | Description | 
| [get_attachment_icon()](https://developer.wordpress.org/reference/functions/get_attachment_icon/)`wp-includes/deprecated.php` |

Retrieve HTML content of icon attachment image element.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/get_attachment_icon_src/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.5.0](https://developer.wordpress.org/reference/since/2.5.0/) | Deprecated. Use [wp_get_attachment_image_src()](https://developer.wordpress.org/reference/functions/wp_get_attachment_image_src/)  | 
| [2.1.0](https://developer.wordpress.org/reference/since/2.1.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_attachment_icon_src%2F)
before being able to contribute a note or feedback.