Media: Make the is_gd_image() function available on front end.

This avoids a fatal error if a plugin calls image creation or editing functions like `wp_imagecreatetruecolor()` outside of the admin.

Follow-up to [48798]

Props BackuPs.
Fixes #51174. See #50833.
Built from https://develop.svn.wordpress.org/trunk@48905


git-svn-id: http://core.svn.wordpress.org/trunk@48667 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2020-08-28 16:45:06 +00:00
parent 12b68c6671
commit af523447f4
3 changed files with 24 additions and 24 deletions

View File

@ -912,29 +912,6 @@ function file_is_displayable_image( $path ) {
return apply_filters( 'file_is_displayable_image', $result, $path );
}
/**
* 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.
*
* @since 5.6.0
*
* @param resource|GdImage|false $image A value to check the type for.
* @return bool True if $image is either a GD image resource or GdImage instance,
* false otherwise.
*/
function is_gd_image( $image ) {
if ( is_resource( $image ) && 'gd' === get_resource_type( $image )
|| is_object( $image ) && $image instanceof GdImage
) {
return true;
}
return false;
}
/**
* Load an image resource for editing.
*

View File

@ -3458,6 +3458,29 @@ function get_taxonomies_for_attachments( $output = 'names' ) {
return $taxonomies;
}
/**
* 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.
*
* @since 5.6.0
*
* @param resource|GdImage|false $image A value to check the type for.
* @return bool True if $image is either a GD image resource or GdImage instance,
* false otherwise.
*/
function is_gd_image( $image ) {
if ( is_resource( $image ) && 'gd' === get_resource_type( $image )
|| is_object( $image ) && $image instanceof GdImage
) {
return true;
}
return false;
}
/**
* Create new GD image resource with transparency support
*

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.6-alpha-48904';
$wp_version = '5.6-alpha-48905';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.