I'm using wp media regenerate to generate thumbnails. While this works for the built-in Wordpress image sizes (even when the width and height are customized in functions.php), it does not work at all for custom image sizes. The command finishes and the custom sizes simply are not generated. The original images are much larger than the sizes being generated, so it's not related to upsampling. I've also tried declaring the custom sizes using the after_setup_theme action hook, but the result was the same. Does wp media regenerate only work for the built-in media sizes, or am I doing something wrong?


// Built-in sizes work
update_option("large_size_w", 2000);
update_option("large_size_h", 9999);
update_option("large_crop", 0);

// Custom sizes don't work
add_image_size("Custom Size", 320, 320, true);
  • Just a guess, but I've never used a name with a space in it for a custom image size before. If you change it to 'custom_size', does it work? Also worth testing is the Regenerate Thumbails plugin, to help narrow down if it's a wp-cli specific issue or something else.
    – Tim Malone
    Commented Oct 3, 2016 at 18:49
  • Thanks for the comment @TimMalone. I did try a custom size name with all lowercase letters and no spaces, but the result was the same. I've also tried the Force Regenerate Thumbnails plugin and it does create the needed sizes, but we have over 40,000 images that need to be processed. We have a script that runs wp-cli on 32 cores, but not all sizes are being generated for whatever reason. Commented Oct 3, 2016 at 19:00

1 Answer 1


I finally figured this out. It ended up being something really stupid. I have short tags enabled on my server so I can use <? instead of <?php in theme files. I was also using a short tag to open my functions.php file. Apparently, when PHP scripts run from the command line, they require the full <?php open tag, otherwise they just echo to the console. I made this change in my functions.php file and it works now.

By the way, if this is useful to anyone else, I wrote a Node.js script for processing massive WordPress media libraries that leverages as many cores as you have (in my case, 32 cores). https://gist.github.com/daveyjones/fe87d99be3d9f0ca4b7786ee5b66c15f

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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