Skip to content
Snippets Groups Projects
Select Git revision
  • 171738e70bd421cf2d611f5be5f0c73e0b9b460e
  • master default protected
  • lintian-fixes
3 results

actions.go

Blame
  • Forked from ai3 / thirdparty / rsyslog-exporter
    Source project has a limited visibility.
    class-wp-image-editor-gd.php 12.48 KiB
    <?php
    /**
     * WordPress GD Image Editor
     *
     * @package WordPress
     * @subpackage Image_Editor
     */
    
    /**
     * WordPress Image Editor Class for Image Manipulation through GD
     *
     * @since 3.5.0
     * @package WordPress
     * @subpackage Image_Editor
     * @uses WP_Image_Editor Extends class
     */
    class WP_Image_Editor_GD extends WP_Image_Editor {
    
    	protected $image = false; // GD Resource
    
    	public function __destruct() {
    		if ( $this->image ) {
    			// we don't need the original in memory anymore
    			imagedestroy( $this->image );
    		}
    	}
    
    	/**
    	 * Checks to see if current environment supports GD.
    	 *
    	 * @since 3.5.0
    	 * @access public
    	 *
    	 * @return boolean
    	 */
    	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'] ) &&
    			 ! function_exists('imagerotate') ){
    
    				return false;
    		}
    
    		return true;
    	}
    
    	/**
    	 * Checks to see if editor supports the mime-type specified.
    	 *
    	 * @since 3.5.0
    	 * @access public
    	 *
    	 * @param string $mime_type
    	 * @return boolean
    	 */
    	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;
    		}