Daryll Doyle WordPress Development and Consultancy in Cornwall

Background Image Resizing in WordPress

B

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

About the author

Daryll Doyle

Daryll is a Lead Web Engineer at 10up.

He is the original author of the SVG sanitisation plugin Safe SVG, which has over 500,000 installs from the WordPress.org plugin directory and is now maintained by 10up.

He has also spoken publicly about SVGs and WordPress, including a talk at WordCamp London 2018.

In his spare time he enjoys spending time with his family and researching Developer Experience.

Add comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Daryll Doyle WordPress Development and Consultancy in Cornwall