定制 jdsdev/craft-embedder 二次开发

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

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

jdsdev/craft-embedder

Composer 安装命令:

composer require jdsdev/craft-embedder

包简介

Generate video embed code.

README 文档

README

Embedder is a plugin for Craft CMS based on Antenna by Vector Media Group that will generate embed code for YouTube, Vimeo, Wistia, or Viddler. It also gives you access to the video’s title, its author, the author’s YouTube/Vimeo URL, and a thumbnail. All you have to do is pass it a single URL.

You can also output various pieces of metadata about the video.

Requirements

This plugin requires Craft 5 or later.

For the Craft 2 version, see the v1 branch

Installation

To install the plugin, follow these instructions.

  1. Open your terminal and go to your Craft project:

     cd /path/to/project
    
  2. Then tell Composer to load the plugin:

     composer require jdsdev/craft-embedder
    
  3. In the Control Panel, go to Settings → Plugins and click the “Install” button for Embedder.

Simple Usage

If used as a single tag (embedder.embed), it returns the HTML embed/object code for the video.

{{ craft.embedder.embed (entry.embedderVideo, {max_width:500, max_height:800}) }}

Full Usage and Variables

If used by setting the video URL, you get access to several variables.

{% set video = craft.embedder.url(entry.embedderVideo, {max_width:500, max_height:800}) %}

{{ video.embed_code }}
<ul>
    <li>title : {{ video.video_title }}</li>
    <li>description : {{ video.video_description }}</li>
    <li>thumbnail : <img src="{{ video.video_thumbnail }}"></li>
</ul>

There are three image sizes available for videos: video_thumbnail, video_mediumres, and video_highres. They are not consistent across services but they should fall into rough size brackets. video_thumbnail is going to be between 100-200px wide; video_mediumres will be around 400-500px wide; and video_highres will be at least the full size of your uploaded video and could be as wide as 1280px.

Parameters

Dimensions

Set the max_width and/or max_height for whatever size your website requires. The video will be resized to be within those dimensions, and will stay at the correct proportions.

  • max_width: 500 - Can be any number. Left unspecified by default.
  • max_height: 800 - Can be any number. Left unspecified by default.

YouTube

If you're using YouTube, you can use any of the supported embed parameters. Simply prefix the parameters with youtube_. Here are some common parameters:

  • youtube_rel: 0 - Show related videos at the end of the video. Can be 0 or 1 (default).
  • youtube_showinfo: 0 - Show the video title overlay. Can be 0 or 1 (default).
  • youtube_controls: 0 - Show the video player controls. Can be 0 or 1 (default).
  • youtube_autoplay: 1 - Automatically start playback of the video. Can be 0 (default) or 1.
  • youtube_enablejsapi: 1 - Enable the YouTube IFrame or JavaScript APIs. Can be 0 (default) or 1.

Additionally the following non-standard parameter is available when using YouTube:

Vimeo

If you're using Vimeo, you can use any of the supported embed parameters. Simply prefix the parameters with vimeo_. Here are some of the common parameters:

  • vimeo_byline: 0 - Shows the byline on the video. Can be 0 or 1 (default).
  • vimeo_title: 0 - Shows the title on the video. Can be 0 or 1 (default).
  • vimeo_portrait: 0 - Shows the user's avatar on the video. Can be 0 or 1 (default).
  • vimeo_loop: 1 - Loops the video playback. Can be 0 (default) or 1.
  • vimeo_autoplay: 1 - Automatically start playback of the video. Can be 0 (default) or 1.
  • vimeo_color: 'ff0000' - Sets the theme color for the Vimeo player. Can be any hexidecimal color value (without the hash). Defaults to '00adef'.

You can also use the following Vimeo parameter:

  • vimeo_player_id: 'myVideoPlayer' - Sets an ID on the player, which is useful if you want to control multiple videos on the same page in a different way.

The following extra variable is available when using Vimeo:

  • {{ video_description }} - The description of the video, as set in Vimeo

Viddler

If you're using Viddler, you get access to two more parameters:

  • viddler_type: 'simple' - Specifies the player type. Can be 'simple' or 'player' (default).
  • viddler_ratio: 'widescreen' - Aspect ratio. Can be 'widescreen', 'fullscreen', or left unspecified for automatically determined aspect ratio.

Wistia

If you're using Wistia, you get access to two more parameters:

  • wistia_type - Sets the supported embed type.
  • wistia_foam: true - Makes the embedded video responsive using Wistia's Video Foam feature.

HTML Output Control

You can also control your output with the following parameters:

  • id: 'myId' - Gives the iFrame an id= attribute with the specified value.
  • class: 'video player' - Gives the iFrame a class= attribute with the specified value.
  • attributes: 'data-video data-player' - Gives the iFrame the specified HTML attribute(s).

wmode (deprecated with most providers)

The optional wmode parameter can be used if you're experiencing issues positioning HTML content in front of the embedded media. It accepts values of transparent, opaque and window.

Contributions

  • Adam Powell - Original plugin author.

  • Aaron Waldon / @aaronwaldon - Reworked the logic to allow any provider parameters to be used. Added HTML output control parameters and updated the documentation.

  • Jonathan Sarmiento - Updated the plugin for Craft 3 and Craft 4.

jdsdev/craft-embedder 适用场景与选型建议

jdsdev/craft-embedder 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10.31k 次下载、GitHub Stars 达 68, 最近一次更新时间为 2019 年 01 月 16 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「cms」 「embedder」 「Craft」 「craftcms」 「craft-plugin」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

围绕 jdsdev/craft-embedder 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 10.31k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 69
  • 点击次数: 9
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 68
  • Watchers: 4
  • Forks: 9
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-01-16