Images make up a large chunk of the bandwidth used by most websites. That makes them an obvious target for optimization. Any reduction in the size of images can have a positive impact on the performance of a website.
Over the last couple of releases, WordPress has introduced several new image optimizations that happen by default. I’ve found that some WordPress users don’t quite understand what is being optimized and what isn’t. An understanding of how WordPress optimizes images is important if site owners are to maximize the opportunity for performance gains, so let’s take a look at what WordPress does with the images you upload to your site.
Responsive images were introduced in WordPress 4.4. They allow WordPress to serve images that are the right size for the screen on which they will be viewed. There’s no need to send an image 2000px across if it will be displayed on the screen of a 4-inch phone.
WordPress has always generated multiple copies of uploaded images in various sizes, but they were only used when the theme called for smaller images — thumbnails are the obvious example. WordPress now uses the images to provide a responsive experience for visitors.
The main limitation of WordPress’ responsive image implementation is that the image sizes generated by WordPress may not be ideal. WordPress’ developers added an extra size — medium — when they implemented responsive images, but the range of sizes may not be appropriate for every design. It’s up to theme developers to make sure that the right image sizes are being generated.
Image Compression And Optimization
WordPress has always carried out some optimizations on the images it generates, but there were changes in WordPress 4.5 that users should be aware of.
By default, images are created with a quality of 82 rather than the previous 90. The numbers are given to the underlying image processing library and indicate how high the quality of the image should be, with 100 being the best.
The reduction in quality is largely theoretical. The images look almost identical to the untrained eye. However, images produced at the lower quality use much less storage space and bandwidth.
Most images contain metadata that isn’t useful to a person looking at the image in a blog article or page. The metadata carries information about the image that is useful in various ways — copyright information, color information, data generated by the camera — that don’t benefit the casual website visitor.
WordPress will now strip out much of that data by default.
What WordPress Doesn’t Do To Optimize Images
In addition to understanding what WordPress does to images, it’s useful to know what it doesn’t do.
Plenty Of Metadata Left
Some of the metadata in images is useful to some people — photographers, for example, aren’t happy if EXIF data is removed. In fact, WordPress doesn’t strip all the metadata from the images it creates. The following data is left alone: EXIF, xmp, and iptc data, and icc and icm color profiles.
If you want to stop WordPress stripping any metadata, you can use the image_strip_meta hook, as explained here.
Your Original Image Is Not Altered
When you upload an image, WordPress creates several versions of that image with different sizes, depending on defaults and theme settings. The increased compression and metadata stripping happen when the new images are being generated. They’re not applied to the original image, which remains the same. If you want the original image, which may well be sent to users, to be optimized, you’ll have to do it yourself with a tool like ImageOptim or a WordPress plugin like EWWW Image Optimizer.
Over the last few years, WordPress has become much better at image optimization, and for the most part, users can just go with the defaults.