function file_is_displayable_image($path) {}

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


  • string $path: File path to test.

Return values

returns:True if suitable, false if not suitable.

Defined filters

  • file_is_displayable_image
    apply_filters('file_is_displayable_image', $result, $path)

Source code

function file_is_displayable_image($path) {

	$info = @getimagesize($path);

	if ( empty($info) )

		$result = false;

	elseif ( !in_array($info[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG)) )	// only gif, jpeg and png images can reliably be displayed

		$result = false;


		$result = true;

	return apply_filters('file_is_displayable_image', $result, $path);



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

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: