Ticket #28634: 28634.6.diff
File 28634.6.diff, 3.4 KB (added by , 9 years ago) |
---|
-
src/wp-includes/class-wp-image-editor-imagick.php
diff --git src/wp-includes/class-wp-image-editor-imagick.php src/wp-includes/class-wp-image-editor-imagick.php index 125ef0d..7e6ffd1 100644
class WP_Image_Editor_Imagick extends WP_Image_Editor { 317 317 * 318 318 * @param bool $strip_meta Whether to strip image metadata during resizing. Default true. 319 319 */ 320 $strip_meta = apply_filters( 'image_strip_meta', $strip_meta ); 321 322 // Strip image meta. 323 if ( $strip_meta ) { 324 $strip_result = $this->strip_meta(); 325 326 if ( is_wp_error( $strip_result ) ) { 327 return $strip_result; 328 } 320 if ( apply_filters( 'image_strip_meta', $strip_meta ) ) { 321 $this->strip_meta(); 329 322 } 330 323 331 324 try { … … class WP_Image_Editor_Imagick extends WP_Image_Editor { 662 655 * @return true|WP_Error True if stripping metadata was successful. WP_Error object on error. 663 656 */ 664 657 protected function strip_meta() { 658 659 static $profiles = array(); 660 661 /** 662 * Filter the list of image profile types that are not stripped. 663 * 664 * This filter only applies when resizing using the Imagick editor since GD 665 * strips all profiles by default. 666 * 667 * @since 4.5.0 668 * 669 * @param array $protected_profiles Array of protected profile types. Default 'icc' and 'iptc'. 670 */ 671 $protected_profiles = apply_filters( 'image_protected_profiles', array( 672 'icc', 673 'iptc', 674 ) ); 675 665 676 try { 666 // Strip profiles. 667 foreach ( $this->image->getImageProfiles( '*', true ) as $key => $value ) { 668 if ( $key != 'icc' && $key != 'icm' ) { 669 $this->image->removeImageProfile( $key ); 670 } 677 // Save profiles before stripping if any our protected. 678 if ( empty( $profiles ) && ! empty( $protected_profiles ) ) { 679 $profiles = $this->image->getImageProfiles( '*', true ); 671 680 } 672 681 673 // Strip image properties. 674 if ( method_exists( $this->image, 'deleteImageProperty' ) ) { 675 $this->image->deleteImageProperty( 'comment' ); 676 $this->image->deleteImageProperty( 'Thumb::URI' ); 677 $this->image->deleteImageProperty( 'Thumb::MTime' ); 678 $this->image->deleteImageProperty( 'Thumb::Size' ); 679 $this->image->deleteImageProperty( 'Thumb::Mimetype' ); 680 $this->image->deleteImageProperty( 'software' ); 681 $this->image->deleteImageProperty( 'Thumb::Image::Width' ); 682 $this->image->deleteImageProperty( 'Thumb::Image::Height' ); 683 $this->image->deleteImageProperty( 'Thumb::Document::Pages' ); 684 } else { 685 $this->image->setImageProperty( 'comment', '' ); 686 $this->image->setImageProperty( 'Thumb::URI', '' ); 687 $this->image->setImageProperty( 'Thumb::MTime', '' ); 688 $this->image->setImageProperty( 'Thumb::Size', '' ); 689 $this->image->setImageProperty( 'Thumb::Mimetype', '' ); 690 $this->image->setImageProperty( 'software', '' ); 691 $this->image->setImageProperty( 'Thumb::Image::Width', '' ); 692 $this->image->setImageProperty( 'Thumb::Image::Height', '' ); 693 $this->image->setImageProperty( 'Thumb::Document::Pages', '' ); 682 $this->image->stripImage(); 683 684 // Loop through protected profile types and write them back to the image. 685 foreach ( $protected_profiles as $profile_type ) { 686 if ( ! empty( $profiles[$profile_type] ) ) { 687 $this->image->profileImage( $profile_type, $profiles[$profile_type] ); 688 } 694 689 } 695 } catch ( Exception $e ) { 690 691 } 692 catch ( Exception $e ) { 696 693 return new WP_Error( 'image_strip_meta_error', $e->getMessage() ); 697 694 } 698 695