Background Image Resizing in WordPress

Since the media changes in WordPress 4.5 there have been a number of reports of upload issues, such as uploads timing out, as mentioned in this trac ticket.

The reason behind this is very possibly due to the changes in the ImageMagick class. Whilst images are now handled better than before, it’s also added slightly more overhead to the code that resizes images. Now for a standard WordPress install you may not see too much of an issue but, once themes and plugins start adding extra image sizes, this can easily lead to the issues previously mentioned.

Back in January, Delicious Brains blogged about a new background processing system they’d built for WordPress, this system was released on Github here.

I recently built a plugin as a test that using this system to move the resizing of images away from the upload handler and into a background queue. It does this by hooking into the intermediate_image_sizes_advanced filter that’s fired just before WordPress starts the resizing of images. If we return false to this filter WordPress won’t resize any images. Using this filter, I added all defined image sizes to a queue to be processed and then returned false. This meant that WordPress by default wouldn’t create any of the image sizes but the background queue will.

Whilst only a test, this plugin is available on Github and can hopefully spark some discussion on the best way to handle this issue.

Plugin is available in the following repo: https://github.com/darylldoyle/WP-Background-Image-Processing

Leave a Reply

Your email address will not be published. Required fields are marked *