Refactor ImageStyleDownloadController so derivatives can be generated by contrib modules

Created on 11 March 2016, almost 9 years ago
Updated 23 October 2023, over 1 year ago

In order to support alternative stream wrappers like S3 and maintain performance, contributed modules often have to reimplement significant parts of the image generation process. For example, with S3 we want to first serve an image locally, and then upload it in the background to mask the several seconds it takes to upload an image.

This patch takes the bare minimum approach, and refactors deliver() into several protected methods. This significantly simplifies the implementation for the Flysystem module, and helps avoid bugs in image token and request validation.

A more complete approach would be to refactor most of the new methods into a separate class that can be unit tested, decoupling generation from a Request object. It looks like that's underway over at #2359443: Allow creating image derivatives from an Image object β†’ , though that patch doesn't address the issues with the deliver() method.

✨ Feature request
Status

Needs work

Version

11.0 πŸ”₯

Component
Image systemΒ  β†’

Last updated about 3 hours ago

Created by

πŸ‡¨πŸ‡¦Canada deviantintegral

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¦πŸ‡ΊAustralia mstrelan

    This is nice, but not help when more than one module needs to override the controller, e.g. stage_file_proxy and webp and avif. I'm wondering if it would be possible to have a service that can be decorated by multiple modules instead? See https://symfony.com/doc/current/service_container/service_decoration.html for details on service decoration in symfony. Then the ::deliver method can just call a method on the service and each module can decorate it with it's own behaviour.

  • last update over 1 year ago
    Patch Failed to Apply
  • πŸ‡«πŸ‡·France DrDam

    Some update here and a "redo" of the patch for Drupal 11

  • πŸ‡«πŸ‡·France DrDam

    [replace patch by a cleaner one]

  • Status changed to Needs review about 1 month ago
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    Can you please put that code on a merge request? Tests don't run against patches anymore.

  • Merge request !107662685905 - refactor ImageStyleDownloadController β†’ (Open) created by DrDam
  • πŸ‡«πŸ‡·France DrDam

    drdam β†’ changed the visibility of the branch 2685905-refactor-imagestyledownloadcontroller-so to hidden.

  • Pipeline finished with Failed
    25 days ago
    Total: 93s
    #384014
  • Pipeline finished with Success
    25 days ago
    Total: 541s
    #384019
  • πŸ‡«πŸ‡·France DrDam

    Merge Request available

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Thanks for converting to an MR.

    Noticed that the summary appears incomplete, would recommend using the standard issue template.

    Also will need test coverage for the new functionality

    Thanks

  • πŸ‡«πŸ‡·France DrDam
  • πŸ‡«πŸ‡·France DrDam

    For test coverage, I don't what it need to be tested, it just code management, no new functionnality.

  • πŸ‡·πŸ‡ΊRussia zniki.ru

    Thanks for MR.
    Do you think we can add interface for these new methods?

  • πŸ‡¬πŸ‡§United Kingdom oily Greater London

    In the issue summary it states

    - with S3...

    What does that mean? With (in the case of) the S3 contributed module? Or with the S3 stream wrapper?

    Then

    ..we want to first serve an image locally..

    Who is 'we'? The reporter's company? Drupal.org?

    How does 'we' 'want to first serve an image locally'? By using or creating a contributed module? Or a custom module?

    I dont know the answers to these questions. If someone would like to update the issue summary or I will if I can get answers to these questions.

  • πŸ‡«πŸ‡·France DrDam

    @nikolay shapovalov :
    "Do you think we can add interface for these new methods?"

    I don't know ...
    The purpose of the RM is simply to separate the processing/generation of the derivatives from the various validation/authorisation operations linked to this generation.

    @oily : I don't know either what @deviantintegral want to say, when it create the issue.
    I just done my best when @smustgrave ask me to update summary to the "good template"
    I have my use case "with mediaContextualCrop, we want to create a new image delivering methodebased on 80% of the ImageStyleDownloadController" for the others I don't know their motivations.

Production build 0.71.5 2024