当前位置: 动力学知识库 > 问答 > 编程问答 >

php - 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.

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.

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...

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(); 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

分享给朋友:
您可能感兴趣的文章:
随机阅读: