disable cropping featured image in wordpress [clos

2019-08-08 05:32发布

I am using featured image as a post image but on uploading a image it crops while setting it as featured image, i dnt find any solution for it, Can any one help?

Wordpress Admin panel screenshot:-

enter image description here

This image is actually 1024x702 but it cuts to 940x198, i cant find any soltuion for this how to disabling the cropping...

2条回答
Ridiculous、
2楼-- · 2019-08-08 05:47

Not sure how to disable cropping but you could try to use add_image_size function to register a bigger image size.

Something like this: (add this in functions.php)

add_image_size( 'featuredImageCropped', 1024, 768, true );

And then locate the_post_thumbnail in the template and modify it like this:

the_post_thumbnail( 'featuredImageCropped' ); 
查看更多
欢心
3楼-- · 2019-08-08 06:03

Inside your theme there is file called functions.php - inside functions.php you will find a line of code similar to this:

add_image_size('featured', 940, 198, true);

These parameters are the name, width, height, and crop.

When crop is set to "true" your image will be resized so that it fills the width-height dimensions completely. The shortest side of the image will be equal to the maximum allowed value, and the longest side of the image will be cropped.

When crop is set to "false" your image will be resized so that it fits inside the width-height dimensions. The longest side of the image will be equal to the maximum allowed value, and the shorter side of the image will be smaller.

I would recommend playing with these settings to achieve the exact effect that you're after. Most likely what you want is not to disable cropping, but rather to simply increase the maximum allowed height of your featured image.

查看更多
登录 后发表回答