Skip to content
Advertisement

update and regenerate thumbnails for wordpress multisite

For my multisite installations (with over 1500 sites on one of them) I am looking for the most efficient way to change the thumbnailsite to 300×300. On a single site you can easily do this by changing the mediasettings and then running the regenerate thumbnails plugin. I don’t want to do this manually for all the sites so I’m thinking about how to do this by code.

To set the thumbnailsize is a part which I can figure out. I’ll just make a loop that loops through all the sites in the network and use the code to update the default thumbnailsettings:

JavaScript

But I can’t figure out how to do the regenerating since I can’t really find advice on how to code this. When I search for this I just find developers recommending the regenerate thumbnails plugin. Also with the code I’m a little bit skeptical it’ll become too heavy for my wpmu.

Is there something code/plugin that can do what I want ? (regenerate thumbnails for the whole network ?)

Advertisement

Answer

With wp cli on the command line you can use the Media regenerate command line for every website:

JavaScript

Then for a large number of sites you can use a loop which could look like that:

JavaScript

For each website in the list i, the command line regenerates medias.

I added the --yes option to Answer yes to the confirmation message.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement