is_gd_image() WordPress Function

The is_gd_image() function is used to check if a given image is a valid GD image.

is_gd_image( resource|GdImage|false $image ) #

Determines whether the value is an acceptable type for GD image functions.


Description

In PHP 8.0, the GD extension uses GdImage objects for its data structures. This function checks if the passed value is either a resource of type gd or a GdImage object instance. Any other type will return false.


Top ↑

Parameters

$image

(resource|GdImage|false)(Required)A value to check the type for.


Top ↑

Return

(bool) True if $image is either a GD image resource or GdImage instance, false otherwise.


Top ↑

Source

File: wp-includes/media.php

function is_gd_image( $image ) {
	if ( is_resource( $image ) && 'gd' === get_resource_type( $image )
		|| is_object( $image ) && $image instanceof GdImage
	) {
		return true;
	}

	return false;
}


Top ↑

Changelog

Changelog
VersionDescription
5.6.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More