WordPress-在不损失质量的情况下裁剪缩略图

WordPress-在不损失质量的情况下裁剪缩略图

问题描述:

我有一个网站上有一个商店"页面.每个产品都有为其分配的缩略图.

I have a website on which there is a "shop" page. Each product has a thumbnail assigned to it.

我使用以下代码设置了自定义缩略图的大小:

I set a custom thumbnail size with this code:

if ( function_exists( 'add_image_size' ) ) { 
   add_image_size( 'products', 150, 84, true );
}

裁切效果很好,但是当图像过高时,WordPress会将其裁切为"height"参数,最终结果是缩略图太窄而无法看起来不错.

Cropping works fine, but when the image is too tall WordPress crops it to the "height" parameter and the final result is a thumbnail too narrow to look good.

有没有一种方法可以使WordPress选择图像的一部分(150x84像素片段)并将其用作缩略图,而不是调整图像的大小?重要的是,缩略图必须精确地保持在150x84像素,而不能太窄或太短.

Is there a way to make WordPress select a part of an image (150x84 px fragment) and use it as a thumbnail instead of resizing the image? It is important for thumbnails to stay at 150x84 px EXACTLY while not being too narrow or too short.

我找到了答案.

即使WordPress在使用我在此使用的功能时确实裁剪了图像,也可能会不正确地进行处理,直到重新生成缩略图为止.简短的答案是:WordPress裁剪了我的图像,但是由于未重新生成缩略图,因此存在缺陷.

Even if WordPress does crop images while using the function I used here, it may do it improperly until thumbnails are regenerated. Short answer is: WordPress cropped my images, but it was flawed due to thumbnails not being regenerated.

要重新生成它们,请使用此插件:

To regenerate them please use this plugin:

重新生成缩略图