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 Staff Engineer at 10up.

With a deep passion for web development and open-source technology, Daryll is the original author of the SVG sanitization plugin Safe SVG, which boasts over 900,000 installs from the WordPress.org plugin directory and is now proudly maintained by 10up.

Throughout his career, Daryll has demonstrated expertise in SVGs and WordPress, sharing his knowledge through public speaking engagements, including a notable talk at WordCamp London 2018.

Beyond his professional life, Daryll enjoys spending quality time with his family and diving into research on Developer Experience, constantly seeking ways to improve the workflow and productivity of fellow developers.

Add comment

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

Daryll Doyle WordPress Development and Consultancy in Cornwall