Class: Alula::VideoTag
- Inherits:
-
Tag
- Object
- Liquid::Tag
- Tag
- Alula::VideoTag
show all
- Defined in:
- lib/alula/core_ext/tags/video.rb
Instance Attribute Summary
Attributes included from LiquidExt
#context
Instance Method Summary
collapse
Methods included from LiquidExt
included, #initialize, #render
Instance Method Details
#content ⇒ Object
14
15
16
|
# File 'lib/alula/core_ext/tags/video.rb', line 14
def content
video_tag(@source)
end
|
#prepare ⇒ Object
5
6
7
8
9
10
11
12
|
# File 'lib/alula/core_ext/tags/video.rb', line 5
def prepare
@info = {}
@options["classes"] ||= []
@options["title"] ||= @options["alternative"]
@options["alternative"] ||= @options["title"]
@options["classes"] += [@options["align"] || "left"]
end
|
#video_tag(source) ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/alula/core_ext/tags/video.rb', line 18
def video_tag(source)
poster = source.gsub(/#{File.extname(source)}$/, '.png')
info = info(poster, :thumbnail)
poster = attachment_url(poster, :thumbnail)
tag = "<video"
tag += " controls"
tag += " class=\"#{(@options["classes"]).join(" ")}\""
tag += " width=\"#{info.width}\""
tag += " height=\"#{info.height}\""
tag += " poster=\"#{poster}\""
tag += " preload=\"none\">"
sources.each do |source|
tag += " <source src=\"#{source[:url]}\" #{source[:hires] ? "data-quality=\"hd\"" : ""} />"
end
tag += "</video>"
end
|