Module: OEmbedHelper

Defined in:
app/helpers/o_embed_helper.rb

Instance Method Summary collapse

Instance Method Details


26
27
28
# File 'app/helpers/o_embed_helper.rb', line 26

def link_to_oembed_image(cache, prefix = 'thumbnail_')
  link_to(oembed_image_tag(cache, prefix), cache.url, :target => '_blank')
end

#o_embed_html(cache) ⇒ Object


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/helpers/o_embed_helper.rb', line 2

def o_embed_html(cache)
  data = cache.data
  data = {} if data.blank?
  title = data.fetch('title', cache.url)
  html = link_to(title, cache.url, :target => '_blank') 
  return html unless data.has_key?('type')
  case data['type']
  when 'video', 'rich'
    if cache.is_trusted_and_has_html?
      html = data['html']
    elsif data.has_key?('thumbnail_url')
      html = link_to_oembed_image(cache)
    end
  when 'photo'
    if data.has_key?('url')
      img_options = cache.options_hash('')
      html = link_to_oembed_image(cache, '')
    end
  else
  end

  return html.gsub('http://', 'https://').html_safe
end

#oembed_image_tag(cache, prefix) ⇒ Object


30
31
32
# File 'app/helpers/o_embed_helper.rb', line 30

def oembed_image_tag(cache, prefix)
  image_tag(cache.data[prefix + 'url'], cache.options_hash(prefix))
end