swisnl/avg-safe-iframes
Composer 安装命令:
composer require swisnl/avg-safe-iframes
包简介
Fix iframe elements in order to comply to AVG
README 文档
README
This package will look for <iframe>-elements in a HTML-snippet, and "fix" it in order to play nicely with our cookiebar.
Install
composer require swisnl/avg-safe-iframes
What it does
- Replace the src-attribute with data-src (so the iframe won't load right away)
- Adds a class to the element (
cookie-settings-*), so the cookiebar knows if it complies with the users preferences. The default class is for tracking-cookies.
How to use it
Via the class:
$avgSafeIframe = new \Swis\AvgSafeIframes\AvgSafeIframes();
$text = '<div><iframe class="foo-bar" src="http:///www.example.com"></iframe></div>';
return $avgSafeIframe->fix($text);
// <div><iframe class="foo-bar cookie-settings-tracking" data-src="http:///www.example.com"></iframe></div>
Via the helper (in a blade-template, for example):
{!! safeAvgIframes($text) !!}
In both scenario's, you could provide a second parameter to add a different class. Please use one of the AvgSafeIframes::MODE*_ constants:
MODE_TRACKINGMODE_STATSMODE_STATS_AND_TRACKING
Todo
- Add a (Laravel) middleware so you won't have to manually use the helper
统计信息
- 总下载量: 2.07k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-05-28