Kirby 3 oEmbed 字段

安装: 98

依赖: 0

建议者: 0

安全性: 0

星星: 2

关注者: 1

分支: 0

公开问题: 0

类型:kirby-plugin

0.0.2 2019-08-14 16:58 UTC

This package is auto-updated.

Last update: 2024-09-28 16:31:11 UTC


README

为 Kirby 添加 oEmbed 功能。

|400

安装

  • 解压 master.zipsite/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() 来访问方法。

静态方法