tvalimaa/iframe_cookie_consent

添加Ckeditor插件,将YouTube iframe嵌入转换为支持cookie同意

1.3.2 2024-08-26 09:47 UTC

This package is auto-updated.

Last update: 2024-09-26 10:02:07 UTC


README

第三方内容提供者(如YouTube)通过iframe加载的内容可能需要设置cookie并因此需要访客的同意。

https://support.cookiebot.com/hc/en-us/articles/360003790854-Iframe-cookie-consent-with-YouTube-example

https://support.cookiebot.com/hc/en-us/articles/360003812053-Hide-and-show-content-based-on-the-visitor-s-consent

在此模块中

此模块添加了Ckeditor插件,该插件将YouTube iframe嵌入转换为支持cookie同意。您可以选择以下值之一作为data-cookieconsent属性:'preferences'、'statistics'或'marketing'。

您可以在内容创作/Ifame cookie同意下找到这些设置

/admin/config/content/iframe_cookie_consent

如何使用

前往配置/内容创作/文本格式和编辑器,并编辑您想要使用Ifame cookie同意的文本格式。

/admin/config/content/formats/

现在在启用过滤器下,您将看到您刚刚启用的Ifame cookie同意

字段支持

YouTube视频可以以多种方式嵌入到内容中,因此支持字段的最简单方法是创建或修改字段模板文件。

以下是一个示例。

<iframe
  {{ attributes }}
  {% if url is not empty %}
    data-cookieblock-src={{ url }}
    data-cookieconsent="marketing"
    class=" cookieconsent-optin-marketing"

    {% if query is not empty %}
      ?{{ query | url_encode }}
    {% endif %}

    {% if fragment is not empty %}
      #{{ fragment }}
    {% endif %}"
  {% endif %}
  >
</iframe>
<div class="cookieconsent-optout-marketing">
   {{ 'Please <a href="javascript:Cookiebot.renew()">accept marketing-cookies</a> to watch this video'|t }}
</div>