1

I have added a new image size to a wordpress site with lots of images already present with all their thumbnails.

Is there a way to do this: given the post using a specific image, get the attachment image and generate the thumbnail of the new size?

I'm looking for a way to do this when needed and only on specific selected posts (it's an image size only used for some posts placed in a "highlighted news" box), so no generic plugins which scan the whole 8gb directory of images, but I'd like to use wordpress tools (basically what it does when you upload an image and all thumbs are generated) instead of doing it all by hand.

EDIT

I will clarify the scenario so that it's more understandable. I have a simple admin tab where the user enters the URLs of the posts that go in a specific highlight box in the homepage. It all works perfectly, except for the images.

What I want to do is this: whenever an URL is entered in that admin panel the image attached to that post must be processed to create a new thumbnail with the recently added image size (since it's a new size, all images predating it do not have the relative thumbnail). This should be an automatic process, otherwise the user has to go to the media library, find the correct image and regenerate its thumbnail, thus losing the simplicity of the original idea.

Basically I'm looking for something like:

wp_generate_thumb($attachment_id, $image_size); // EXAMPLE, function not really existing

which should just accept the attachment id and the string of the image size defined with add_image_size() and take care of everything else.

The closest I found is this wp_get_image_editor() which doesn't really seem to do what I need.

  • so you don't want to use plugin for it right ? – nirmal Apr 20 '15 at 9:14
0

Is there some plugins that allows you to regerate images size via media library and not regenrate all, look at second shot:

https://wordpress.org/plugins/regenerate-thumbnails/screenshots/

Also it does multiple image selection.

0

Found out that the answer was these two functions:

https://codex.wordpress.org/Function_Reference/wp_generate_attachment_metadata https://codex.wordpress.org/Function_Reference/wp_update_attachment_metadata

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.