Featured image is small and low-quality compared to original image

大兔子大兔子 提交于 2021-01-28 10:01:51

问题


When I upload a featured image in Wordpress, it decreases the size of image. The quality of images is also much lower than original images. How can I get Wordpress to have larger, higher-quality featured images?


回答1:


Here You can give the size of thumbnails in parameter of get_the_post_thumbnail() function in array like this:

echo  get_the_post_thumbnail($id, array(100,100) );



回答2:


You can change the size of your thumbnail images under Settings > Media. As for the quality of the image, you can adjust how much jpeg compression (assuming you're using jpegs) wordpress uses when shrinking your original image down to thumbnail size. Add the following to your functions.php file.

add_filter( 'jpeg_quality', create_function( '', 'return 90;' ) );

You can crank that 90 right up to 100 if you like, but you will end up with larger image file sizes.

Note that this only affects any new images you upload to the site — i.e., WordPress won't automatically re-save thumbnail (and Medium and Large if applicable) version of all the images you've already uploaded. But you can force regeneration of thumbnail images with a plugin like... wait for it... Regenerate Thumbnails. It's also especially handy if you've just changed your image sizes in the Media settings. I use this plugin all the time. It's pretty rad.




回答3:


Yo can define new image sizes with these:

add_image_size( $name, $width, $height, $crop );

And then you can use it in your theme with these:

the_post_thumbnail( $name );


来源:https://stackoverflow.com/questions/13600937/featured-image-is-small-and-low-quality-compared-to-original-image

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!