WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 2 down vote accepted

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.

share|improve this answer

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.


Just use a plugin :)

share|improve this answer

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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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