• Resolved spinhead

    (@spinhead)


    Is it possible to set thumbnail sizes with wp-cli? I see a command to read, but not write.

    Looking for a way to include this in my install script. 150px square thumbnails are so last millennium.

    The page I need help with: [log in to see the link]

Viewing 8 replies - 1 through 8 (of 8 total)
  • Moderator threadi

    (@threadi)

    You can regenerate thumbnails via WP CLI as described here: https://developer.wordpress.org/cli/commands/media/regenerate/

    However, you must also define the new dimension beforehand. This is not possible via WP CLI as the website in the frontend must also know which dimensions are available. This is usually done with individual programming, e.g. through an addition to the theme. There is also a plugin that can help with this: https://wordpress.org/plugins/better-image-sizes/

    Thread Starter spinhead

    (@spinhead)

    Since this is for new installs it seems there would be no need to regenerate thumbnails.

    I know thumbnail sizes can be set in the admin screen. I just prefer to do as much as possible through my install script.

    Thread Starter spinhead

    (@spinhead)

    I’m going to experiment with

    set_post_thumbnail_size

    to see if that’s what I’m looking for, since I can add that to functions.php in my theme.

    Thread Starter spinhead

    (@spinhead)

    Appears that ‘post thumbnail’ means ‘Featured Image’ which is not what I’m looking for.

    Moderator threadi

    (@threadi)

    What is your actual goal with this question?

    Thread Starter spinhead

    (@spinhead)

    As I said in my original post: when creating new installs for clients, I use scripts. I want to automate changing the media sizes programmatically during the installation so I don’t have to go into the interface afterward and make changes as I am now.

    Moderator threadi

    (@threadi)

    You have already seen the media configuration option in the backend. What is saved there is ultimately only saved in the database in the options table. You could therefore change this data record via WP CLI (can be done via https://developer.wordpress.org/cli/commands/option/) and then regenerate the images as described above.

    Thread Starter spinhead

    (@spinhead)

    wp option is the solution.

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘change thumbnail sizes with wp-cli’ is closed to new replies.