[wp-trac] [WordPress Trac] #48522: Attachment size not generated when large images uploaded

WordPress Trac noreply at wordpress.org
Wed Nov 13 23:07:55 UTC 2019


#48522: Attachment size not generated when large images uploaded
-------------------------------+---------------------
 Reporter:  vanyukov           |       Owner:  (none)
     Type:  defect (bug)       |      Status:  new
 Priority:  normal             |   Milestone:  5.3.1
Component:  Media              |     Version:  5.3
 Severity:  normal             |  Resolution:
 Keywords:  reporter-feedback  |     Focuses:
-------------------------------+---------------------

Comment (by vanyukov):

 As per discussion from Slack, I'm moving the discussion to trac.

 I see three possible solutions to the problem.

 1. Adjust the resample size

 In my tests, this change fixes the issue: inside wp-includes/class-wp-
 image-editor-imagick.php (around line 343) instead of:
 {{{#!php
 $this->image->sampleImage( $dst_w * $sample_factor, $dst_h *
 $sample_factor );
 }}}
 try to dynamically adjust the {{{$sample_factor}}}:
 {{{#!php
 do {
     try {
         unset( $e );
         $this->image->sampleImage( $dst_w * $sample_factor, $dst_h *
 $sample_factor );
     } catch ( Exception $e ) {
         $sample_factor--;
         continue;
     }

     break;
 } while ( $sample_factor > 0 );

 if ( isset( $e ) && $e instanceof ImagickException ) {
     throw $e;
 }
 }}}
 My main concern is that this change might not be the best way to go
 forward without doing proper DSSIM tests to make sure that there is no
 visible change in images with the new resample size. The previous tests
 were done a while back and, I believe, the max-width tested was 1200px.
 Much has changed since then.

 2. Error handle this.

 The problem with this approach - it does not fix the initial issue. There
 will still be no guaranteed way to resize large attachments.

 3. Fallback to GD

 I can see that this is not an issue with GD. So maybe use GD as a default
 editor when both ImageMagick and GD are installed? Currently
 {{{_wp_image_editor_choose()}}} is set to return
 {{{WP_Image_Editor_Imagick}}} by default. Also an easy fix.

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


More information about the wp-trac mailing list