[wp-trac] [WordPress Trac] #40010: Regression for #36749. Uploading an image into site_icon breaks customizer

WordPress Trac noreply at wordpress.org
Thu Mar 23 05:53:41 UTC 2017


#40010: Regression for #36749. Uploading an image into site_icon breaks customizer
--------------------------+--------------------
 Reporter:  aussieguy123  |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  4.7.4
Component:  Customize     |     Version:  trunk
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |     Focuses:
--------------------------+--------------------

Comment (by aussieguy123):

 @westonruter its a part of our new authoring plugin. Relevant functions
 are:

 {{{#!php
 <?php
 class Image_Crop_Handler {
         public $wp_image_sizes_to_remove = array( 'thumbnail', 'medium',
 'large', 'full' );

         /**
          * Remove default WordPress image sizes.
          *
          * @param $attachment
          *
          * @filter wp_prepare_attachment_for_js
          *
          * @return mixed
          */
         public function remove_non_spp_image_sizes( $attachment ) {
                 $attachment = $this->replace_full_size_label( $attachment
 );
                 if ( empty( $attachment['sizes'] ) ) {
                         return $attachment;
                 }

                 foreach ( $attachment['sizes'] as $label => $attributes )
 {
                         if ( ! $this->is_valid_spp_image_size( $label,
 $attributes ) ) {
                                 unset( $attachment['sizes'][ $label ] );
                         }
                 }

                 return $attachment;
         }

         /**
          * Whether the image size is a valid SPP image size or not
          *
          * @param $label
          * @param $attributes
          *
          * @return bool
          */
         public function is_valid_spp_image_size( $label, $attributes ) {
                 if ( in_array( $label, $this->wp_image_sizes_to_remove,
 true ) ) {
                         return false;
                 }

                 if ( isset( $this->image_sizes[ $label ] ) ) {
                         $height = $this->image_sizes[ $label ]['height'];
                         $width  = $this->image_sizes[ $label ]['width'];

                         if ( $height !== $attributes['height'] || $width
 !== $attributes['width'] ) {
                                 return false;
                         }
                 }

                 return true;
         }
 }
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/40010#comment:17>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list