Discover in this tutorial how to get images not to lose quality when uploading them to WordPress with a simple code snippet.
By default, WordPress compresses the JPG images you upload to the media library to 82% quality.
It does this because, in general, it is difficult to appreciate the loss of quality and with this step it manages to reduce the weight of the file.
And you know that the less a page weighs, the faster it loads. 😉
So far so good. But the problem comes when, for some reason (for example, because it has overlapping text) the image loses more quality than you would like.
Don’t panic! You can prevent this from happening
How? By using the WordPress
Snippet to keep the quality of the images you upload to WordPress at 100%
Add the following code at the end of functions.php or in your functionality plugin:
It’s that simple, can you see?
jpg_quality filter allows you to set the quality you want WordPress to apply when uploading your images.
With this code block you mark 100 regarding the original image quality.
While in general you can keep the compression used by WordPress, it is good to have this snippet handy in case you want some of the images you upload to preserve all their quality, don’t you think?
Of course, you can also play with other values, as long as they are between 0 and 100. Although I recommend, as a general rule, to stay between 70-100% quality.
Now you know how to prevent images from losing quality when uploading them to the WordPress media library.
It is an ideal trick when you have an image or photograph that you want to look in all its splendor.
Any questions? Let me know in the comments.
And if you want to give me any suggestion for future tutorials, leave it in the contact form. Advantages of being a subscriber. 😉