druidfi / iframe_cookie_consent
添加 Ckeditor 插件,将 iframe 嵌入转换为支持 Cookie 许可
1.3.2
2023-08-11 11:35 UTC
Requires
- php: ^8.0
- ext-dom: *
- ext-libxml: *
- drupal/core: ^9.5 || ^10.0
- masterminds/html5: ^2.7
README
第三方内容提供者(如 YouTube)在 iframe 中加载的网站内容可能需要设置 Cookie,并因此需要访客的同意。
本模块功能
此模块添加了 Ckeditor 插件,可以将 YouTube iframe 嵌入转换为支持 Cookie 许可。您可以选择以下其中一个值作为 data-cookieconsent 属性: preferences
、statistics
或 marketing
。
您可以在内容创建 / Iframe Cookie 许可下找到这些设置
/admin/config/content/iframe_cookie_consent
如何使用
前往配置 / 内容创建 / 文本格式和编辑器,并编辑您想使用 Iframe Cookie 许可模块的文本格式。
/admin/config/content/formats/
现在在已启用过滤器下,您将看到刚刚启用的 Iframe 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>