class Dato::Local::FieldType::Video

Attributes

height[R]
provider[R]
provider_uid[R]
provider_url[R]
thumbnail_url[R]
title[R]
url[R]
width[R]

Public Class Methods

new( url, thumbnail_url, title, width, height, provider, provider_url, provider_uid ) click to toggle source
# File lib/dato/local/field_type/video.rb, line 22
def initialize(
  url,
  thumbnail_url,
  title,
  width,
  height,
  provider,
  provider_url,
  provider_uid
)
  @url            = url
  @thumbnail_url  = thumbnail_url
  @title          = title
  @width          = width
  @height         = height
  @provider       = provider
  @provider_url   = provider_url
  @provider_uid   = provider_uid
end
parse(value, _repo) click to toggle source
# File lib/dato/local/field_type/video.rb, line 9
def self.parse(value, _repo)
  value && new(
    value[:url],
    value[:thumbnail_url],
    value[:title],
    value[:width],
    value[:height],
    value[:provider],
    value[:provider_url],
    value[:provider_uid],
  )
end

Public Instance Methods

iframe_embed(width = self.width, height = self.height) click to toggle source
# File lib/dato/local/field_type/video.rb, line 42
def iframe_embed(width = self.width, height = self.height)
  # rubocop:disable Layout/LineLength
  case provider
  when "youtube"
    %(<iframe width="#{width}" height="#{height}" src="//www.youtube.com/embed/#{provider_uid}?rel=0" frameborder="0" allowfullscreen></iframe>)
  when "vimeo"
    %(<iframe src="//player.vimeo.com/video/#{provider_uid}?title=0&amp;byline=0&amp;portrait=0" width="#{width}" height="#{height}" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>)
  when "facebook"
    %(<iframe src="//www.facebook.com/plugins/video.php?href=#{url}&width=#{width}&show_text=false&height=#{height}" width="#{width}" height="#{height}" style="border:none;overflow:hidden;width:100%;" scrolling="no" frameborder="0" allowTransparency="true" allow="encrypted-media" allowFullScreen="true"></iframe>)
  end
  # rubocop:enable Layout/LineLength
end
to_hash(*_args) click to toggle source
# File lib/dato/local/field_type/video.rb, line 55
def to_hash(*_args)
  {
    url: url,
    thumbnail_url: thumbnail_url,
    title: title,
    width: width,
    height: height,
    provider: provider,
    provider_url: provider_url,
    provider_uid: provider_uid,
  }
end