Changeset 48798 for trunk/src/wp-admin/includes/image.php
- Timestamp:
- 08/16/2020 01:31:57 PM (5 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-admin/includes/image.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/image.php
r48586 r48798 914 914 915 915 /** 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 for 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 /** 916 939 * Load an image resource for editing. 917 940 * … … 919 942 * 920 943 * @param string $attachment_id Attachment ID. 921 * @param string $mime_type Image mime type. 922 * @param string $size Optional. Image size, defaults to 'full'. 923 * @return resource|false The resulting image resource on success, false on failure. 944 * @param string $mime_type Image mime type. 945 * @param string $size Optional. Image size. Default 'full'. 946 * @return resource|GdImage|false The resulting image resource or GdImage instance on success, 947 * false on failure. 924 948 */ 925 949 function load_image_to_edit( $attachment_id, $mime_type, $size = 'full' ) { … … 943 967 break; 944 968 } 945 if ( is_resource( $image ) ) { 969 970 if ( is_gd_image( $image ) ) { 946 971 /** 947 972 * Filters the current image being loaded for editing. … … 949 974 * @since 2.9.0 950 975 * 951 * @param resource $image Current image.952 * @param string $attachment_id Attachment ID.953 * @param string $size Image size.976 * @param resource|GdImage $image Current image. 977 * @param string $attachment_id Attachment ID. 978 * @param string $size Image size. 954 979 */ 955 980 $image = apply_filters( 'load_image_to_edit', $image, $attachment_id, $size ); 981 956 982 if ( function_exists( 'imagealphablending' ) && function_exists( 'imagesavealpha' ) ) { 957 983 imagealphablending( $image, false ); … … 959 985 } 960 986 } 987 961 988 return $image; 962 989 } … … 972 999 * 973 1000 * @param string $attachment_id Attachment ID. 974 * @param string $size Optional. Image size, defaults to'full'.1001 * @param string $size Optional. Image size. Default 'full'. 975 1002 * @return string|false File path or url on success, false on failure. 976 1003 */
Note: See TracChangeset
for help on using the changeset viewer.