WordPress automatically compresses JPG files, which can hurt your websites load speed and SEO.JPG is related to the Joint Photographic Experts Group (JPEG) image file format. JPG files also have 2 sub formats, JPG/Exif which is used in digital cameras and photographic equipment, and JPG/JFIF which is often used on the internet. Whenever you upload an image to WordPress media library it will automatically compress your images to 90% quality, this is to size a bit of bandwidth on displaying images on your web page.
But if your a photographer and you want to always have the highest quality images on your site then you can change the default compression to 100% quality. All you have to add the following to your functions.php file, this will run when compressing your images and return the value of the quality you want.
To do WordPress to compress your JPEG images, you have to paste the following code in your theme’s functions.php file or your site-specific plugin.
add_filter('jpeg_quality', function($arg){return 100;});
Setting it to 100 would mean that WordPress would compress the image at its highest quality. For most users, this is not an issue. Heck, we never noticed it on our site. But if you are a photographer, then this is noticeable (we suppose).
There are definitely performance benefits to leaving the compression quality as is. If you want, you can change the number from 100 to 80 or something lower to squeeze a few more kBs.
Thanks to WP Snippets for the tip!
