Title: file_is_displayable_image
Published: April 25, 2014
Last modified: May 20, 2026

---

# file_is_displayable_image( string $path ): bool

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/file_is_displayable_image/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/file_is_displayable_image/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/file_is_displayable_image/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/file_is_displayable_image/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/file_is_displayable_image/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/file_is_displayable_image/?output_format=md#changelog)

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

Validates that file is suitable for displaying within a web page.

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

 `$path`stringrequired

File path to test.

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

 bool True if suitable, false if not suitable.

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

    ```php
    function file_is_displayable_image( $path ) {
    	$displayable_image_types = array( IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG, IMAGETYPE_BMP, IMAGETYPE_ICO, IMAGETYPE_WEBP, IMAGETYPE_AVIF );

    	$info = wp_getimagesize( $path );
    	if ( empty( $info ) ) {
    		$result = false;
    	} elseif ( ! in_array( $info[2], $displayable_image_types, true ) ) {
    		$result = false;
    	} else {
    		$result = true;
    	}

    	/**
    	 * Filters whether the current image is displayable in the browser.
    	 *
    	 * @since 2.5.0
    	 *
    	 * @param bool   $result Whether the image can be displayed. Default true.
    	 * @param string $path   Path to the image.
    	 */
    	return apply_filters( 'file_is_displayable_image', $result, $path );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-admin/includes/image.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-admin/includes/image.php#L1172)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-admin/includes/image.php#L1172-L1193)

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

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

Filters whether the current image is displayable in the browser.

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

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

Allows PHP’s getimagesize() to be debuggable when necessary.

  | 
| [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.

  |

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

Generates attachment meta data and create image sub-sizes for images.

  |

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

| Version | Description | 
| [2.5.0](https://developer.wordpress.org/reference/since/2.5.0/) | Introduced. |

## User Contributed Notes

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