特色图像尺寸css,Wordpress 3.2.1特色图像尺寸和裁剪(Wordpress 3.2.1 Featured Image Size and Crop)...

Wordpress 3.2.1特色图像尺寸和裁剪(Wordpress 3.2.1 Featured Image Size and Crop)

我需要帮助找到在帖子中更改特色图像的大小和裁剪的位置和方式。 我查看了functions.php和init.php,但没有成功。 我正在使用inLine主题的子主题。

当前高度设置为130px。

我尝试过改变css,但这只能拉伸图像。

I need help finding where and how to change the size and crop of a featured image within a post. I've looked in functions.php and init.php, but with no success. I'm using a child theme of the inLine theme.

The current height is set for 130px.

I've tried changing the css, but that only stretches the image.

原文:https://stackoverflow.com/questions/7839420

更新时间:2019-11-19 00:39

最满意答案

在您的functions.php中,粘贴其中一个并根据您的喜好调整像素宽度和高度:

set_post_thumbnail_size( 100, 100 ); // 100 pixels wide by 100 pixels tall, box resize mode

要么:

set_post_thumbnail_size( 100, 100, true ); // 100 pixels wide by 100 pixels tall, hard crop mode

In your functions.php, paste one of these and adjust pixel width and height to your liking:

set_post_thumbnail_size( 100, 100 ); // 100 pixels wide by 100 pixels tall, box resize mode

OR:

set_post_thumbnail_size( 100, 100, true ); // 100 pixels wide by 100 pixels tall, hard crop mode

相关问答

Add the following code into your function.php hope the solution of answer

the_post_thumbnail('large'); // Large resolution (default 640px x 640px max)

Add the following code into your function.php hope the solution of answer

the_post_thumbnail('l

...

在您的functions.php中,粘贴其中一个并根据您的喜好调整像素宽度和高度: set_post_thumbnail_size( 100, 100 ); // 100 pixels wide by 100 pixels tall, box resize mode

要么: set_post_thumbnail_size( 100, 100, true ); // 100 pixels wide by 100 pixels tall, hard crop mode

In your functi

...

缩略图仅生成一次(上传时)。 因此,添加新的add_image_size()调用不会影响任何已上传的图像。 您需要重新生成缩略图,例如使用Regenerate Thumbnails插件 。 Actually installing "php-gd2" on my server resolved the issue. Initially it was running "php-gd" library. Thanks everyone

你应该去wp-admin->includes->post.php和第1295行(取决于版本)你会发现: if ( !empty( $thumbnail_html ) ) {

$ajax_nonce = wp_create_nonce( 'set_post_thumbnail-' . $post->ID );

$content = sprintf( $set_thumbnail_link, $upload_iframe_src, $thumbnail_html );

$con

...

是的,你可以这样做,只需转到functions.php并定义所需的大小,例如如下: - add_image_size( 'first', 80, 80, true );

add_image_size( 'second', 120, 120, true );

add_image_size( 'third', 180, 180, true );

之后,您可以在要显示特定图像大小的位置定义所需大小,如下所示: - the_post_thumbnail('first');

the_post_thumbn

...

也许这是你想要的,注意应用的CSS。 还有: // Generate Random Color

function getRandomColor() {

var letters = '0123456789ABCDEF'.split('');

var color = '#';

for (var i = 0; i < 6; i++ ) {

color += letters[Math.floor(Math.random() * 16)];

}

ret

...

Scissors不适合你,因为你使用的是Wordpress 2.9吗? 似乎有人为Wordpress 2.9创建了Scissors的修改版本 。 最大图像大小控制似乎也提供此功能。 不过,我自己没有使用过这些插件。 祝你好运! Does Scissors not work for you because you are using Wordpress 2.9? It appears someone has created a modified version of Scissors for Wor

...

不确定如何禁用裁剪,但您可以尝试使用add_image_size函数来注册更大的图像大小。 像这样:(在functions.php中添加) add_image_size( 'featuredImageCropped', 1024, 768, true );

然后在模板中找到the_post_thumbnail并将其修改为: the_post_thumbnail( 'featuredImageCropped' );

Not sure how to disable cropping but yo

...

add_image_size('small-thumbnail', 180, 120, true);

更改180和120值(宽度和高度),你应该很好。 此资源也可能对您有所帮助: https://wordpress.org/support/topic/set-featured-image-size 您还可以使用名为Simple Image Sizes的插件来控制这些值 I fixed my own problem. In the index.php I was using small_thumb

...

图像缩小,因为当图像实际为1903px时,最大宽度设置为“1900px”。 The image is scaling down because there's a max-width set of "1900px" when the image is actually 1903px.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值