Class: Alula::ImageTag
- Inherits:
-
Tag
- Object
- Liquid::Tag
- Tag
- Alula::ImageTag
show all
- Defined in:
- lib/alula/core_ext/tags/image.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
16
17
18
19
20
21
22
23
|
# File 'lib/alula/core_ext/tags/image.rb', line 16
def content
hires = hires_url(@source, :image)
tag = "<a href=\"#{attachment_url(@source, :image)}\""
tag += " data-hires=\"#{hires}\"" if context.site.config.attachments["image"]["hires"] and hires and !self.context.item.metadata.renderer.class.to_s[/FeedBuilder/]
tag += ">"
tag += imagetag(@source, :thumbnail)
tag += "</a>"
end
|
#imagetag(source, type, opts = {}) ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/alula/core_ext/tags/image.rb', line 25
def imagetag(source, type, opts = {})
src = attachment_url(source, type)
hires = hires_url(source, type)
classes = opts.delete(:classes) || @options["classes"]
unless @options['alternative'] or @options['title']
@options['title'] = info(source, type).title
@options['alternative'] = info(source, type).title
end
tag = "<img"
tag += " alt=\"#{@options["alternative"]}\"" if @options["alternative"]
tag += " title=\"#{@options["title"]}\"" if @options["title"]
tag += " class=\"#{classes.join(" ")}\""
if context.site.config.attachments.image.lazyload and !self.context.item.metadata.renderer.class.to_s[/FeedBuilder/]
tag += " src=\"#{asset_url("grey.gif")}\""
tag += " data-original=\"#{src}\""
else
tag += " src=\"#{src}\""
end
tag += " data-hires=\"#{hires}\"" if context.site.config.attachments.image.hires and hires and !self.context.item.metadata.renderer.class.to_s[/FeedBuilder/]
tag += " width=\"#{info(source, type).width}\" height=\"#{info(source, type).height}\""
tag += " />"
end
|
#prepare ⇒ Object
7
8
9
10
11
12
13
14
|
# File 'lib/alula/core_ext/tags/image.rb', line 7
def prepare
@info = {}
@options["classes"] ||= []
@options["title"] ||= @options["alternative"]
@options["alternative"] ||= @options["title"]
@options["classes"] += [@options["align"] || "left"]
end
|