Project

General

Profile

Actions

Feature #96477

open

Fluid media element - privacy option (loading after accepting a cookie)

Added by Stephan Bauer over 2 years ago. Updated 9 months ago.

Status:
Under Review
Priority:
Should have
Assignee:
-
Category:
Fluid
Target version:
-
Start date:
2022-01-07
Due date:
% Done:

0%

Estimated time:
PHP Version:
Tags:
Complexity:
Sprint Focus:

Description

Media elments link youtube videos should not load immediately because of ePrivacy etc.
The usually solution is to change the 'src' tag to 'data-src' and let some JS do the loading.
The only this that is missing is to define an option if you want 'data-src' or not.

With this little code it would be possible to use the media element:
(plus lazy loading which is supported by Chrome https://caniuse.com/?search=loading)

diff -ru typo3_src-10.4.22.orig/typo3/sysext/core/Classes/Resource/Rendering/YouTubeRenderer.php typo3_src-10.4.22/typo3/sysext/core/Classes/Resource/Rendering/YouTubeRenderer.php
--- typo3_src-10.4.22.orig/typo3/sysext/core/Classes/Resource/Rendering/YouTubeRenderer.php    2021-12-14 09:06:06.000000000 +0100
+++ typo3_src-10.4.22/typo3/sysext/core/Classes/Resource/Rendering/YouTubeRenderer.php    2022-01-07 00:05:37.000000000 +0100
@@ -95,8 +95,13 @@
         $src = $this->createYouTubeUrl($options, $file);
         $attributes = $this->collectIframeAttributes($width, $height, $options);

+        $privacy = "";
+        if ($options['privacy']) {
+            $privacy = "data-";
+        }
         return sprintf(
-            '<iframe src="%s"%s></iframe>',
+            '<iframe ' . $privacy . 'src="%s"%s></iframe>',
             htmlspecialchars($src, ENT_QUOTES | ENT_HTML5),
             empty($attributes) ? '' : ' ' . $this->implodeAttributes($attributes)
         );
@@ -209,7 +214,7 @@
         if (isset($GLOBALS['TSFE']) && is_object($GLOBALS['TSFE']) && (isset($GLOBALS['TSFE']->config['config']['doctype']) && $GLOBALS['TSFE']->config['config']['doctype'] !== 'html5')) {
             $attributes['frameborder'] = 0;
         }
-        foreach (['class', 'dir', 'id', 'lang', 'style', 'title', 'accesskey', 'tabindex', 'onclick', 'poster', 'preload', 'allow'] as $key) {
+        foreach (['class', 'dir', 'id', 'lang', 'style', 'title', 'accesskey', 'tabindex', 'onclick', 'poster', 'preload', 'allow', 'loading'] as $key) {
             if (!empty($options[$key])) {
                 $attributes[$key] = $options[$key];
             }
diff -ru typo3_src-10.4.22.orig/typo3/sysext/fluid/Classes/ViewHelpers/MediaViewHelper.php typo3_src-10.4.22/typo3/sysext/fluid/Classes/ViewHelpers/MediaViewHelper.php
--- typo3_src-10.4.22.orig/typo3/sysext/fluid/Classes/ViewHelpers/MediaViewHelper.php    2021-12-14 09:06:06.000000000 +0100
+++ typo3_src-10.4.22/typo3/sysext/fluid/Classes/ViewHelpers/MediaViewHelper.php    2022-01-06 23:52:27.000000000 +0100
@@ -87,6 +87,7 @@
         $this->registerArgument('cropVariant', 'string', 'select a cropping variant, in case multiple croppings have been specified or stored in FileReference', false, 'default');
         $this->registerArgument('fileExtension', 'string', 'Custom file extension to use for images');
         $this->registerArgument('loading', 'string', 'Native lazy-loading for images property. Can be "lazy", "eager" or "auto". Used on image files only.');
+        $this->registerArgument('privacy', 'string', 'Load media after a cookie is accepted.');
     }

     /**
Actions #1

Updated by Georg Ringer over 2 years ago

  • Status changed from New to Needs Feedback

Thanks for creating this feature request.
The big issue I see is this will produce a non working output as you need some cookie consent solution which covers:

  • tell user about third party content
  • checking if user allows this type of content
  • JS to change the data-src back to src.

especially because TYPO3 does not (yet) ship any frontend and because there are multiple extensions outthere providing everything already I am unsure if this issue can be set to closed?

Actions #2

Updated by Stephan Bauer over 2 years ago

Thanks for your feedback.

For me the media VH is not usable anymore because media links like youtube are loaded immediately and there is no way to block this. This is against GDPR.
I would like to have a solution for this in the core.

There are already some changes made so that the core is compatible with GDPR.

With this option I could use core functionalities.

I dont' think that it is necessary to include an extenstion like dp_cookieconsent into the core.

Actions #3

Updated by Georg Ringer over 2 years ago

  • Status changed from Needs Feedback to Accepted

thanks for your feedback!

Actions #4

Updated by Gerrit Code Review 9 months ago

  • Status changed from Accepted to Under Review

Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/80514

Actions #5

Updated by Max Frerichs 9 months ago

Georg Ringer wrote in #note-1:

Thanks for creating this feature request.
The big issue I see is this will produce a non working output as you need some cookie consent solution which covers:

  • tell user about third party content
  • checking if user allows this type of content
  • JS to change the data-src back to src.

especially because TYPO3 does not (yet) ship any frontend and because there are multiple extensions outthere providing everything already I am unsure if this issue can be set to closed?

I agree with you that adding an option like that could break output in frontend without proper client-side handling through JavaScript, but imho it makes sense to provide integrators / developers with an option to use data-src attribute instead of src attribute, especially for external-loaded media like YouTube or Vimeo.

Maybe an additional optional argument with proper default values in media VH (something like data-src), evauluated in YouTubeRenderer.php and VimeoRenderer.php, that render some iframe, can solve this issue.
I've uploaded a patchset. Feedback is appreciated!

Actions #6

Updated by Gerrit Code Review 9 months ago

Patch set 2 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/80514

Actions #7

Updated by Stephan Bauer 9 months ago

Please add 'loading' also.

Actions #8

Updated by Gerrit Code Review 9 months ago

Patch set 3 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/80514

Actions #9

Updated by Gerrit Code Review 9 months ago

Patch set 4 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/80514

Actions #10

Updated by Gerrit Code Review 9 months ago

Patch set 5 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/80514

Actions #11

Updated by Gerrit Code Review 9 months ago

Patch set 6 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/80514

Actions

Also available in: Atom PDF