简体   繁体   English

如何在Wordpress中的现有帖子上重新创建特色图片

[英]How to recreate featured image on existing posts in wordpress

I have launched numerous picture blogs already, only to realize recently that all of my post featured image use the full picture. 我已经建立了许多图片博客,直到最近才意识到我的所有精选图片都使用了完整图片。

This means that on my home grid, I have like 6Mo of pictures to load, since the thumbnails are the full picture, only it's resized. 这意味着在我的家庭网格中,我喜欢加载6Mo的图片,因为缩略图是完整图片,只有它可以调整大小。

I would like to be able, in batch, for the full picture 1.jpg, create a thumbnail like 1-300x250.jpg and place it in the featured image. 我希望能够批量处理1.jpg的全图,创建一个像1-300x250.jpg这样的缩略图并将其放置在精选图像中。

I unfortunately couldn't find any plugins that would allow me to do that. 不幸的是,我找不到任何能让我做到这一点的插件。

I hope that someone of you can help me. 我希望你们中有人可以帮助我。

regards. 问候。

Firstly you'll want to register a thumbnail size that you want in your functions.php file... 首先,您需要在functions.php文件中注册所需的缩略图大小...

add_theme_support('post-thumbnails');
set_post_thumbnail_size (70, 70, true);
add_image_size('home-post', 300, 250, true);

Then install the regenerate thumbnails plugin 然后安装重新生成的缩略图插件

With that plugin you can regenerate all the post images to the sizes specified in your functions file. 使用该插件,您可以将所有帖子图像重新生成为功能文件中指定的大小。

After this all you need to do is go into the code that outputs your home grid and wherever it says the_post_thumbnail(); 之后,您所需要做的就是进入输出您的家庭网格的代码,无论代码在何处显示the_post_thumbnail(); make sure you pass the specific name for the image size you specified in your functions file... 确保为函数文件中指定的图像大小传递特定名称...

the_post_thumbnail('home-post');

That should do it. 那应该做。

Regards 问候

Dan

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM