Make WordPress Core


Ignore:
Timestamp:
08/16/2020 01:31:57 PM (4 years ago)
Author:
SergeyBiryukov
Message:

Code Modernization: Introduce is_gd_image() to check for PHP 8 GdImage object instances.

In PHP 8, the GD extension uses GdImage objects instead of resources for its underlying data structures.

This updates the existing is_resource() calls for image resources in core to accomodate for GdImage instances as well.

Props ayeshrajans, jrf.
Fixes #50833.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/deprecated.php

    r48695 r48798  
    31973197 *
    31983198 * @param string $file Filename of the image to load.
    3199  * @return resource The resulting image resource on success, Error string on failure.
     3199 * @return resource|GdImage|string The resulting image resource or GdImage instance on success,
     3200 *                                 error string on failure.
    32003201 */
    32013202function wp_load_image( $file ) {
     
    32183219    $image = imagecreatefromstring( file_get_contents( $file ) );
    32193220
    3220     if ( ! is_resource( $image ) ) {
     3221    if ( ! is_gd_image( $image ) ) {
    32213222        /* translators: %s: File name. */
    32223223        return sprintf( __( 'File “%s” is not an image.' ), $file );
Note: See TracChangeset for help on using the changeset viewer.