0

Just trying to get a scope of work estimation for a project I need done.

My wordpress theme has a custom menu that works best with featured image thumbnails that are 50x50 pixels in size. If the user builds their site after installing my theme, its no problem, since I'm ensuring that all uploads create a 50x50 thumbnail image.

However, if the user installs my theme into an existing site, I have no way of knowing what size their thumbnails are.

Is it possible to create a loop over the thumbnails and do this?

2

There are lots of plugins that do this one way or another including:

I wouldn't recommend reinventing the wheel. If you're particularly worried about it, you might looking into TGM Plugin Activation to suggest to people in the Dashboard that they install and use the plugin.

| improve this answer | |
1

It's certainly possible, there are a number of plugins out there that do exactly this, so you may want to have a peek at how they do it. You should probably do it asynchronously so as not to bring the server to a grinding halt, so that part may be a bit complicated.

Querying for all attachments will get you the attachment IDs, get_attached_file will get you the image path for each ID, wp_generate_attachment_metadata will generate the intermediate image sizes and create the image meta data, and wp_update_attachment_metadata will save the new data back to the server.

EDIT

Just use a plugin :)

| improve this answer | |
0

While I normally don't like "there's a Plugin for that" type answers, in this case: there's a Plugin for that.

| improve this answer | |

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.