WordPress Snippets at WPcustoms

Change jpg compression level

WordPress generates various image sizes which is handled by your theme’s config. They all get generated with a jpg quality of 90. Reduce filesave and save bandwith by lowering the compression level to i.e. 75%. This is still an acceptable quality level but it`s up to you – Change it to 100 if you need 99% loss free jpgs.


/**
 * Snippet Name: Change jpg compression level
 * Snippet URL: https://wpcustoms.net/snippets/change-jpg-compression-level/
 */
  function wpc_jpeg_quality() {
	return 75;
}
add_filter( 'jpeg_quality', 'wpc_jpeg_quality' );