From af523447f46c351cb27432813273049777fbb890 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Fri, 28 Aug 2020 16:45:06 +0000 Subject: [PATCH] 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 --- wp-admin/includes/image.php | 23 ----------------------- wp-includes/media.php | 23 +++++++++++++++++++++++ wp-includes/version.php | 2 +- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/wp-admin/includes/image.php b/wp-admin/includes/image.php index f089fc8201..e719b63428 100644 --- a/wp-admin/includes/image.php +++ b/wp-admin/includes/image.php @@ -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. * diff --git a/wp-includes/media.php b/wp-includes/media.php index 2a9307ae65..e1091b9d8e 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -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 * diff --git a/wp-includes/version.php b/wp-includes/version.php index 638a9a658c..279eef3c10 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.