• Resolved Keith

    (@keithkhl)


    Today I found Performance Lab’s Modern Image Formats – WordPress plugin | www.remarpro.com that helps me to convert all images to AVIF.

    Given that, I’d like to remove all earlier images in my /uploads/ folders and regenerate them in AVIF.

    There must be wp cli options, but I can’t find relevant information.

    Below is what I intend to do.

    First, remove all scaled images and just keep the original jp(e)g, png, and gif. (There are PDF files in the upload folder, but it is not scaled, so irrelevant.)

    Second, generate AVIF version of each image.

    Third, re-generate WP’s 3 default image sizes (thumnail, medium, and large), which I can find from WP Admin -> Settings -> Media

    My theme is already adjusted to require only 3 default image sizes.

    I have changed themes multiple times, and there are over 10 scaled images for each original, along with WebP converted ones.

    Removing WebP and scaled images shouldn’t be that difficult. Just sudo rm to all *.webp and filenames with -xxx-xxx (x being numbers) should be effective. Generating AVIF version of each image is also easy that I just need to run imagemagick (recommend me if there is any better compiler).

    For the third step, is there any WP CLI command?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Brian Alexander

    (@ironprogrammer)

    Hi, @keithkhl ???? I think you’re in luck here, in terms of simplifying the above workflow. The plugin description covers a few things you’ve mentioned above.

    After backing up your site (including the /uploads folder), install Modern Image Formats, activate it, and confirm the desired settings under Settings > Media. By default this will set the generated output image format to AVIF.

    Then in your server shell, run the WP-CLI command wp media regenerate. This automatically removes and replaces generated size files, which should now be AVIF. (This is basically the same as using Regenerate Thumbnails.) Any original JPEG uploads will remain, but sub-sizes will be AVIF. It will also save a *-jpg.avif or -scaled.avif version for each of those JPEGs (handy to compare the loss from JPEG->AVIF in case you want to tweak the quality and re-regenerate).

    It’s intentional that the originally uploaded files (JPEGs) are retained, as they will likely have the best resolution. There are other plugins that may replace originals with a generated/compressed version, but I would recommend caution when modifying originals that you may not be able to restore later on.

    Let me know how this works for you!

    Moderator Support Moderator

    (@moderator)

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Remove all scaled images and regenerate them with AVIF’ is closed to new replies.