Make WordPress Core


Ignore:
Timestamp:
08/28/2020 04:43:31 PM (5 years ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

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

    r48799 r48905  
    914914
    915915/**
    916  * Determines whether the value is an acceptable type for GD image functions.
    917  *
    918  * In PHP 8.0, the GD extension uses GdImage objects for its data structures.
    919  * This function checks if the passed value is either a resource of type `gd`
    920  * or a GdImage object instance. Any other type will return false.
    921  *
    922  * @since 5.6.0
    923  *
    924  * @param resource|GdImage|false $image A value to check the type for.
    925  * @return bool True if $image is either a GD image resource or GdImage instance,
    926  *              false otherwise.
    927  */
    928 function is_gd_image( $image ) {
    929     if ( is_resource( $image ) && 'gd' === get_resource_type( $image )
    930         || is_object( $image ) && $image instanceof GdImage
    931     ) {
    932         return true;
    933     }
    934 
    935     return false;
    936 }
    937 
    938 /**
    939916 * Load an image resource for editing.
    940917 *
Note: See TracChangeset for help on using the changeset viewer.