Review main Merged

68764[FEATURE] Add decoding attribute to images

Chris Müller CR +2 V +2 Normal +50 −2 updated 05/01/21, 12:00

Commit message

This change adds the decoding attribute to images. For better rendering
performance the default value is set to "async" (which decodes images
in content elements asynchronously from the main rendering thread).

See also: https://html.spec.whatwg.org/multipage/images.html#decoding-images

Review

  • Code review CR +2 Done
    • Benni Mack +2
    • Guido Schmechel +1
  • Verified V +2 Done
    • Benni Mack +2
    • Guido Schmechel +1
    • core-ci +1 CI

Issues 1

Files 6

Review log 1215

  1. Chris Müller uploaded patch set 1 04/12/21, 17:57

  2. TYPO3com voted on patch set 1 V +1 04/12/21, 18:03 Completed build in 06m 30s on Mon, 12 Apr, 06:03 PM Test Summary: 33267 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-10624

  3. core-ci voted on patch set 1 V +1 04/12/21, 18:07 Core CI is happy: https://core.b13.com/typo3-core/typo3.cms/-/pipelines/2202

  4. Anja Leichsenring voted on patch set 1 V +1 CR +1 04/18/21, 06:38

  5. Guido Schmechel commented on patch set 1 04/18/21, 16:54

    From a purely functional point of view, everything works. Maybe we can extend the ImageViewHelper UnitTest to check for these 4 allowed attributes (sync, async, auto, ''), just like you do in the code? Knowing that the logic is also missing for the lazy attribute ;-)
  6. Richard Haeser commented on patch set 1 04/19/21, 09:57

    Doing some performance checks if the default value will be a good option in 99% of the cases.
  7. Martin Kutschker commented on patch set 1 04/23/21, 11:22

    Reply

    I had opted for not setting async by default. After all "auto" is the default by supporting browsers. I tried to find articles which gives hints when to use "async". So far I assume it's best used for (large) images above the fold. OTOH, wouldn't this case be handled already by decoding=async?
  8. Chris Müller commented on patch set 1 04/25/21, 18:03

    Reply

    Here is a good introduction: https://dexecure.com/blog/image-decoding/ The decoding=async hands the decoding over to another thread, so the content can be rendered faster. There can be one drawback: When you rely on that the image is decoded already (=displayed on the page) synchroneous to the content. I only can think of something with JavaScript. But that should be hardly with default content elements shipped by TYPO3. But for me it's also okay to set the default parameter to "auto". As it influences the rendering of the content (which should be faster with decoding=async) this has only relevance to the displayed content AFAIK (=above the fold, whatever that fold is).

    Reply

    There are missing also some other attributes, like usemap, longdesc, ismap. However, I tried it but struggled about all the mocking (the addAttribute method on TagBuilder is not used for loading, decoding, etc. A helping hand would be nice.
  9. Martin Kutschker commented on patch set 1 04/25/21, 18:50

    Reply

    Longdesc is dead. It has never been adopted by assisitie technologies (eg screen readers). As you can always use additionalAttributes support for specific attributes is ususally only convenience method. If "async" will be set as default, then of course the attribute must be supported explicitely.
  10. Chris Müller uploaded patch set 2 04/29/21, 17:49

  11. Chris Müller commented on patch set 2 04/29/21, 17:55

    Reply

    Set the default to the empty value in constants.

    Reply

    That might be, that "longdesc" is dead, it was only an example. Writing a test will test the registerArgument/registerTagAttribute methods, if they work correctly. But this is pure Fluid logic. So basically, I can check, if the registerArgument with the correct arguments is called with a mock. But I don't find any example of this in other view helpers (like the link view helpers). So, what to do now?
  12. core-ci voted on patch set 2 V +1 04/29/21, 17:59 Core CI is happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/10928

  13. Guido Schmechel commented on patch set 2 V +1 CR +1 05/01/21, 10:12

    Reply

    I've had a look at the posts and we don't need to be more specific here. In my eyes, this is not part of the patch and the added logic does not require an extended test structure. I had imagined that it would be easier. But it isn't. For me: It's fine now :-) Thx for clarification.
  14. Benni Mack commented on patch set 2 V +2 CR +2 05/01/21, 12:00

    Nice one. Had a look at the browser implementation etc as well. It seems like a good approach to add this (just like lazy loading). Great feature!
  15. Benni Mack merged patch set 3 05/01/21, 12:00