is_gd_image() – Determines whether the value is an acceptable type for GD image functions.

Description

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

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.

Usage

$bool = is_gd_image( $image );

Parameters

$image
( resource|GdImage|false ) required – A value to check the type for.

Returns

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

Source

File name: wordpress/wp-includes/media.php
Lines:

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

  return false;
}
 

 View on GitHub View on Trac

Invoked by

    Call hooks

    API Letters: ,