WordPress 4.5 includes a few performance enhancements for images.
Increased image compression for custom sizes
WordPress 4.5 increases the amount of compression applied to intermediate sizes by changing the default quality in
WP_Image_Editor from 90 to 82. As noted in the proposal for this change, this results in a noticeable reduction in file sizes with little change in visual quality. Developers can override the default image quality value using the
wp_editor_set_quality filter Filters are one of the two types of Hooks https://codex.wordpress.org/Plugin_API/Hooks. They provide a way for functions to modify data of other functions. They are the counterpart to Actions. Unlike Actions, filters are meant to work in an isolated manner, and should never have side effects such as affecting global variables and output..
Improved resizing settings for ImageMagick
For sites making use of ImageMagick, we’ve reduced file sizes further by resizing images more efficiently in
WP_Image_Editor_Imagick and by stripping extraneous metadata using the new
For now, ‘icc’ and ‘icm’ color profiles are retained, along with ‘exif’, ‘xmp’, and ‘iptc’ profiles, which can contain copyright and orientation data. Those who want to retain additional metadata can disable profile stripping by adding a callback function to the
image_strip_meta hook that returns
Note that the original full sized images uploaded to WordPress are unaffected by these changes.
As Jeremy Felt mentioned in his post on Multisite changes,
wp_upload_dir() received a major performance overhaul in this release. Those changes were pared with the addition of a new function,
wp_get_upload_dir(), which can be used as a more performant way to display information about the uploads directory on the front end. This is particularly useful when building URLs for images in templates. (See #34359)
#4-5, #dev-notes, #images, #media, #optimization, #performance