0

I want to create very tiny thumbnails that I can use in my sidebar. I want them to be around 5kb in size and be created automatically from the featured images.

What's the best way to do that?

1

I can't speak for the size of the image, but I assume small images that have a dimension about 50px should have the size around 5 or 10kb. You can add your own custom size to your theme:

add_image_size( 'tiny-thumbnails', 50, 50, true );

Setting the fourth parameter to true will force the WordPress to crop the thumbnails, so they will be exactly 50px in width and 50px in height.

Now, calling this function will get you your tiny thumbnails:

the_post_thumbnail_url( $post_id ,'tiny-thumbnails' );

Don't forget to regenerate the thumbnails after adding this code to your theme's functions.php file.

You can also tweak with the JPG quality, to reduce the size of your thumbnails (which also reduces the quality!). The jpeg_quality filter allows you to do this.

// Set your quality to any value you wish. Values below 70 are not recommended
add_filter('jpeg_quality', function($arg){ return 85; });
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.