Proposed resolution

  • Image without a specific transformation should use default image transformations settings from the config form
  • Image with a specific transformation should use the specific transformation defined by used in the media library instead of the default image transformations

Remaining tasks

  • Extend Asset model to collect derived information during media creation.
    • raw_transformation only matters
  • Create a new field to the cloudinary image media type
    • Custom transformation (field_cloudinary_transformation, text plain long, optional, hidden)
  • When creating media in CloudinaryMedia class, store raw_transformation if any in the new field.
  • Update CloudinaryMedia::find() to take into account raw_transformation to create unique media entities but with the same file.
  • Update CloudinaryMedia::createFile() to check if there is already existing file by the uri
    • If so return the loaded file.
  • Create a custom formatter
    Cloudinary Image
    based on the
    ImageFormatterBase, no settings available
    • Only applicable for cloudinary image media type. Use isApplicable() method.
  • Provide output similar to ImageFormatter::viewElements()
  • Create a new service to generate file uri based on the media entity. You can get a media entity from the $item. e.g.
    $media = $item->getEntity();
    
    • Append custom transformations from field_cloudinary_transformation to the uri if any
    • Append default transformations from the config form to the uri if there are no custom one available
    • Example uri
      cloudinary://c_scale,q_auto,w_200/samples/animals/three-dogs.jpg
      
  • Put a custom uri in $item variable. It will be automatically picked up by
    template_preprocess_image_formatter()
    e.g.
    $item->uri = 'custom uri goes here';
    
  • Export configs and out in the config/install of the module

Issue fork cloudinary-3283530

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

nginex created an issue. See original summary.

sdstyles’s picture

Assigned: Unassigned » sdstyles
nginex’s picture

Issue tags: +D9 Porting
nginex’s picture

Issue summary: View changes

sdstyles’s picture

Assigned: sdstyles » nginex
Status: Active » Needs review

  • 1191843 committed on 2.x
    Issue #3283530: Apply image transformation for stream wrapper.
    
nginex’s picture

Assigned: nginex » Unassigned
Status: Needs review » Fixed

I've provided some fixes and improvements.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.