Skip to content

Generate renditions for all images uploaded to magento #1476

@sivaschenko

Description

@sivaschenko

Description

Currently when the image is uploaded to the media gallery, the thumbnail is created for the image. The idea is to use a similar approach for generating the optimized version of the image.

  • When image is uploaded to the media gallery the optimized version of the image should be created ("Rendition")
  • Rendition should be created based on width/height specified in the configuration of MediaGalleryRenditions module
  • If the image width is greater than the width specified in the configuration - the image should be resized to the configuration width
  • If the image height is greater than the height specified in the configuration - the image should be resized to the configuration height
  • The image should be resized proportionally
  • Resized version of the image should be saved to the .renditions directory
  • Image path/name should be generated using the same approach as thumbnail generation
    (see \Magento\Cms\Model\Wysiwyg\Images\Storage::resizeFile)

Implementation

  • A \Magento\MediaGalleryRenditionsApi\Api\GenerateRentitionsInterface should be introduced with a single method execute(string $path): void
  • An interface should be implemented by \Magento\MediaGalleryRenditions\Model\GenerateRentitions
  • GenerateRentitionsInterface should be used to execute rendition generation during the image upload

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions