tasinttttttt / oembed
Kirby 3 oEmbed 字段
0.0.2
2019-08-14 16:58 UTC
Requires
- php: >=7.1.0
- getkirby/composer-installer: ^1.1
This package is auto-updated.
Last update: 2024-09-28 16:31:11 UTC
README
为 Kirby 添加 oEmbed 功能。
安装
- 解压 master.zip 到
site/plugins/oembed
文件夹或 - 使用
git submodule add https://github.com/tasinttttttt/kirby-oembed.git site/plugins/oembed
或 使用
composer require tasinttttttt/oembed
设置
在蓝图(Blueprint)中
myfield: type: oembed title: My oEmbed Field
在文件(File)中
... Myfield: - https://www.youtube.com/watch?v=M6zR09nn9gE ...
在模板(Template)中
<?php // Import css and js to render iframes echo css('media/plugins/tasinttttttt/oembed/oembed.css'); echo js('media/plugins/tasinttttttt/oembed/oembed.js'); // Necessary to get access field methods. $oembed = $page->myfield()->toOembed(); // Outputs an iframe with clickable thumbnail and autoplay echo $oembed->getEmbed();
模板方法
你需要调用 $page->fieldname()->toOembed()
来访问方法。