承接 viget/craft-video-embed 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

viget/craft-video-embed

Composer 安装命令:

composer require viget/craft-video-embed

包简介

Generate an embed URL from a YouTube or Vimeo URL

README 文档

README

Generate an embed URL from a YouTube or Vimeo URL.

Requirements

This plugin requires Craft CMS 5.0.0 or later.

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 viget/craft-video-embed
    
  3. In the Control Panel, go to Settings → Plugins and click the “Install” button for Video Embed.

Using Video Embed

Pass a YouTube or Vimeo URL to the getVideoData method and a VideoData object is returned.

If the plugin is unable to parse the URL, null is returned.

  • type - If the video is youtube or vimeo
  • id - The ID of the video
  • image - The thumbnail of the video (only works for Youtube)
  • embedUrl - The URL you would use for the embed
  • url - The link to the embedded video
  • isVertical - true for YouTube Shorts (vertical/portrait) videos, otherwise false. Detected from the /shorts/ URL form, not the video's true orientation.

Example:

{% set video = craft.videoEmbed.getVideoData('https://www.youtube.com/watch?v=6xWpo5Dn254') %}

{% if video %}
   <iframe src="{{ video.embedUrl }}"></iframe>
{% endif %}

Output:

<iframe src="https://www.youtube.com/embed/6xWpo5Dn254?rel=0"></iframe>

YouTube embed URLs include rel=0 so related-video suggestions stay on the same channel rather than promoting unrelated videos.

Customizing URL params

Because embedUrl already carries a query string (YouTube's rel=0, or a Vimeo privacy h hash), add your own player params with Craft's built-in url() function rather than concatenating onto embedUrl. url() preserves the existing params and merges in your own:

<iframe src="{{ url(video.embedUrl, { autoplay: 1, mute: 1 }) }}"></iframe>
{# → https://www.youtube.com/embed/6xWpo5Dn254?rel=0&autoplay=1&mute=1 #}
Code At Viget

Visit code.viget.com to see more projects from Viget.

统计信息

  • 总下载量: 67.22k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 24
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 24
  • Watchers: 25
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-09-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固