Skip to content
This repository has been archived by the owner on Nov 22, 2023. It is now read-only.

craftplugins/embed

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Important

This plugin is no longer maintained.

We recommend the Embedded Assets plugin or the oEmbed plugin instead.

Embed plugin for Craft CMS

Craft CMS plugin that extracts information about web pages, like Youtube videos, Twitter statuses or blog articles.

Usage

Embed comes with two methods for extracting information from links; Fields, which can be included in control panel entry types, and a plugin service, which can be used in both templates and other plugins.

Field

Links entered into the Embed field are validated.

{{ entry.embedField.html }}

Here are the default properties provided:

  • type
  • version
  • url
  • title
  • description
  • authorName
  • authorUrl
  • providerName
  • providerUrl
  • cacheAge
  • thumbnailUrl
  • thumbnailWidth
  • thumbnailHeight
  • html
  • width
  • height

Templates

The same properties are made available via the template variable and plugin service.

Below is an example for extracting embed code from a YouTube link, including styling to ensure it’s responsive.

{% set info = craft.embed.extract('https://www.youtube.com/watch?v=NPoHPNeU9fc') %}

<div class="responsive">
  {{ info.html }}{# Outputs whatever HTML has been extracted #}
</div>

{# Calculate ratio for padding #}
{% set ratio = (info.height|default(9) / info.width|default(16)) %}

<style>
  .responsive {
    position: relative;
    padding-bottom: {{ ratio * 100 }}%;
  }
  .responsive > * {
    position: absolute;
    top: 0;
    width: 100%;
    height: 100%;
  }
</style>

Providers

Support is available for the follow providers as well as well-formed Open Graph tagged links.

23hq                Deviantart          Kickstarter         Sketchfab
Animoto             Dipity              Meetup              SlideShare
Aol                 Dotsub              Mixcloud            SoundCloud
App.net             Edocr               Mobypicture         SpeakerDeck
Bambuser            Flickr              Nfb                 Spotify
Bandcamp            FunnyOrDie          Official.fm         Ted
Blip.tv             Gist                Polldaddy           Twitter
Cacoo               Gmep                PollEverywhere      Ustream
CanalPlus           HowCast             Prezi               Vhx
Chirb.it            Huffduffer          Qik                 Viddler
CircuitLab          Hulu                Rdio                Videojug
Clikthrough         Ifixit              Revision3           Vimeo
CollegeHumor        Ifttt               Roomshare           Vine
Coub                Imgur               Sapo                Wistia
CrowdRanking        Instagram           Screenr             WordPress
DailyMile           Jest                Scribd              Yfrog
Dailymotion         Justin.tv           Shoudio             Youtube