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?
functions.php
// 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);
1 Answer
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