wppaste
WordPress

WP_Image_Editor_GD

Since
3.5.0
Source
wp-includes/class-wp-image-editor-gd.php:16
WordPress Image Editor Class for Image Manipulation through GD

Compatibility

WordPress
since 3.5.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Hooks and filters fired · 2

Every hook that fires from inside WP_Image_Editor_GD, in the order it appears in the class, grouped by the method that fires it.

Properties · 1

$imageresource|GdImageprotected
GD Resource.

Methods · 17

Source code

class WP_Image_Editor_GD extends WP_Image_Editor {	/**	 * GD Resource.	 *	 * @var resource|GdImage	 */	protected $image; 	public function __destruct() {		if ( $this->image ) {			if ( PHP_VERSION_ID < 80000 ) { // imagedestroy() has no effect as of PHP 8.0.				// We don't need the original in memory anymore.				imagedestroy( $this->image );			}		}	} 	/**	 * Checks to see if current environment supports GD.	 *	 * @since 3.5.0	 *	 * @param array $args	 * @return bool	 */	public static function test( $args = array() ) {		if ( ! extension_loaded( 'gd' ) || ! function_exists( 'gd_info' ) ) {			return false;		} 		// On some setups GD library does not provide imagerotate() - Ticket #11536.		if ( isset( $args['methods'] ) &&			in_array( 'rotate', $args['methods'], true ) &&			! function_exists( 'imagerotate' ) ) { 				return false;		} 		return true;	} 	/**	 * Checks to see if editor supports the mime-type specified.	 *	 * @since 3.5.0	 *	 * @param string $mime_type	 * @return bool	 */	public static function supports_mime_type( $mime_type ) {		$image_types = imagetypes();		switch ( $mime_type ) {			case 'image/jpeg':				return ( $image_types & IMG_JPG ) !== 0;			case 'image/png':				return ( $image_types & IMG_PNG ) !== 0;			case 'image/gif':				return ( $image_types & IMG_GIF ) !== 0;			case 'image/webp':				return ( $image_types & IMG_WEBP ) !== 0;			case 'image/avif':				return ( $image_types & IMG_AVIF ) !== 0 && function_exists( 'imageavif' );		} 		return false;	} 	/**	 * Loads image from $this->file into new GD Resource.	 *	 * @since 3.5.0	 *	 * @return true|WP_Error True if loaded successfully; WP_Error on failure.	 */	public function load() {		if ( $this->image ) {			return true;		} 		if ( ! is_file( $this->file ) && ! preg_match( '|^https?://|', $this->file ) ) {

Changelog

Introduced in 3.5.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 6.9.7 tag, from src/wp-includes/class-wp-image-editor-gd.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.