定制 sylvainjule/embed 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sylvainjule/embed

Composer 安装命令:

composer require sylvainjule/embed

包简介

Embed field for Kirby

README 文档

README

Embed field for Kirby 3, 4 and 5. Display embeds from various media sites (Youtube, Vimeo, Souncloud, Instagram, etc.) by only providing the url to the medium. Built on top of oscarotero/Embed.

embed-screenshot

Overview

This plugin is completely free and published under the MIT license. However, if you are using it in a commercial project and want to help me keep up with maintenance, you can consider making a donation of your choice.

1. Installation

K3: up to 1.1.0, K4: up to 1.1.2, K5: 1.2.0+

Download and copy this repository to /site/plugins/embed

Alternatively, you can install it with composer: composer require sylvainjule/embed


2. Blueprint usage

The plugin provides a embed field that you can include in any blueprint:

fields:
  embed:
    label: Embed
    type: embed

You have access to all providers supported by oscarotero/Embed. Please note that I won't include any provider unsupported by this library.

You can optionally limit the allowed provider to one within this list : youtube, vimeo, flickr, instagram, twitter, soundcloud. If any other link is pasted, the field won't request the embed.

embed:
  type: embed
  provider: youtube

If you are using this field in a structure field, it comes with a built-in preview. You can optionally set icons: true (default is false) to display some providers logos in this preview.

embed:
  type: embed
  icons: true

embed-icons

The field also has all the url field's options, except those which wouldn't make much sense for such a plugin (default for example), won't fetch anything in the backstage.


3. Options

3.1. nocookie

Use privacy-enhanced URLs whenever possible (default: false). If set to true:

  • youtube.com domain will be replaced by youtube-nocookie.com in the saved embed code
  • vimeo.com iframes will have a dnt=1parameter added in the saved embed code

In your config.php file:

'sylvainjule.embed.nocookie' => true

4. Front-end usage

The plugin provides a ->toEmbed() method, which is useful to get all the stored data of the embed (its html code, and a few other informations detailed below).

It also allows you to make sure your embed is successfully synced before trying to access the data:

if($embed = $page->myfield()->toEmbed()) {
    echo $embed->code()
}

Once you have access to the structured embed, here are the options you will have access to as if they were fields (this comes handy because depending on the provider, some informations might be empty. You can therefore check them with the usual Kirby field methods, like $embed->license()->isEmpty()).

$embed->title();        // The page title
$embed->description();  // The page description
$embed->url();          // The canonical url
$embed->type();         // The page type (link, video, image, rich)
$embed->tags();         // The page keywords (tags)

$embed->image();         // The main image found in the page

$embed->code();          // The code to embed the image, video, etc
$embed->width();         // The width of the embed code
$embed->height();        // The height of the embed code
$embed->aspectRatio();   // The aspect ratio (width / height)

$embed->authorName();    // The resource author
$embed->authorUrl();     // The author url

$embed->providerName();  // The provider name of the page (Youtube, Twitter, Instagram, etc)
$embed->providerUrl();   // The provider url
$embed->providerIcon();  // The main icon found in the page

$embed->publishedDate(); // The published date of the resource
$embed->license();       // The license url of the resource
$embed->feeds();         // The RSS/Atom feeds

A global site method is available to request embed data $site->getEmbedData($url)).

$url = 'https://www.youtube.com/watch?v=XXX';
$site->getEmbedData($url);

5. License

MIT


6. Credits

Built on top of oscarotero/Embed.

With the help of @tristantbg. 👨‍💻

Kirby 2 field by @distantnative, from which I've copy-pasted some bits of this readme. 👀

sylvainjule/embed 适用场景与选型建议

sylvainjule/embed 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 13.74k 次下载、GitHub Stars 达 77, 最近一次更新时间为 2019 年 09 月 05 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 sylvainjule/embed 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 sylvainjule/embed 我们能提供哪些服务?
定制开发 / 二次开发

基于 sylvainjule/embed 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 13.74k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 77
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 77
  • Watchers: 6
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-09-05