Skip to content

Flushing Generated Images

Media Optimization stores the resized and converted images it generates. When you change global settings or replace a source image, you may need to remove those generated files so they regenerate with the new settings.

Removing Resized and Converted Images

Use the following bin/magento command to remove generated images:

bin/magento hyva:media-optimization:clear [options] [--] [<path>]

Argument:

  • <path>: the path of the media item to clear.

Clears everything if no path is given

Running the command without a <path> removes all optimized media.

Options:

  • --converted-only: clears only converted media.
  • --resized-only: clears only resized media.

Examples

Clear all optimized media:

bin/magento hyva:media-optimization:clear

Clear the optimized versions of a specific image:

bin/magento hyva:media-optimization:clear catalog/product/m/b/mb01-blue-0.jpg

Clear only converted formats while preserving resized versions:

bin/magento hyva:media-optimization:clear --converted-only

When to Clear

Clear the entire optimized media cache when you change global optimization settings such as output formats or quality. This regenerates all images with the new settings.

Clear a specific image when you replace an original but keep the same filename, since the cache does not automatically detect that the source has changed.