Debugging upload problem: What part of WP does actual image-resizing?

I have a problem when uploading large images: images larger then (approx) 2000×2000 aren’t generating thumbnails. The file is uploaded fine, but no resized version are generated. No errors are shown. If I upload a smaller one, everything works fine and smaller sizes are generated (ex: test-100x100.jpg)

I’ve contacted my hosting support because I thought this would be a php-gd problem, but support said everything was fine. Here what we have ruled out:

  • Permission problems
  • Out of disk space
  • Out of memory (works fine on a server with half the amount of memory)
  • Max upload limit (in WP and on server)

We even tried another server with the exact same setup, and everything works fine here.

  • I use a clean copy of the latest version WP. no plugins activated
  • I’ve tried plugins which regenerates thumbnails, but even here all processes end successfully without errors, but no resizing was done.

So I’m no trying to manually debug WP, and I’m having trouble finding the exact file where uploaded files are handled and resized.

If found some classes in /wp-includes:

  • class-wp-image-editor.php
  • class-wp-image-editor-gd.php

But it seems none of them are used during an upload. ( I’ve put die() in various functions)

1 Answer
1

You can add a filter to wp_image_editors and see what editor is in use (GD or Imagick). In a past project I’ve extended the resize routines on both GD, and Imagick, and the methods responsible for resize are WP_Image_Editor_Imagick->crop() and WP_Image_Editor_GD->_resize().

Note that WP_Image_Editor_GD->resize() is just a wrapper.

The process it’s run on ajax, but you can use var_dump() to debug it – it will show up on uploaded image messages, the box with progress bar and all.

add_filter( 'wp_image_editors', 'wp23092013_extend_image_editor' );

function wp23092013_extend_image_editor( $editor ) {
    var_dump( $editor );
    return $editor;
}

Happy debugging 😉

Leave a Comment