Class: Maglev::Content::Image
- Inherits:
-
Base
- Object
- Base
- Maglev::Content::Image
show all
- Defined in:
- app/components/maglev/content/image.rb
Instance Attribute Summary
Attributes inherited from Base
#content, #scope, #setting
Instance Method Summary
collapse
Methods inherited from Base
#asset_host, #dom_data, #initialize, #tag_data, #tag_id
Instance Method Details
#alt_text ⇒ Object
20
21
22
|
# File 'app/components/maglev/content/image.rb', line 20
def alt_text
image[:alt_text]
end
|
#height ⇒ Object
16
17
18
|
# File 'app/components/maglev/content/image.rb', line 16
def height
image[:height]
end
|
#tag(view_context, options = {}) ⇒ Object
28
29
30
31
32
33
34
35
36
|
# File 'app/components/maglev/content/image.rb', line 28
def tag(view_context, options = {})
view_context.tag(:img,
{
src: url,
alt: alt_text,
data: (options.delete(:data) || {}).merge(tag_data)
}.merge(options),
false)
end
|
#to_s ⇒ Object
24
25
26
|
# File 'app/components/maglev/content/image.rb', line 24
def to_s
url
end
|
#url ⇒ Object
6
7
8
9
10
|
# File 'app/components/maglev/content/image.rb', line 6
def url
return image[:url] if asset_host.nil? || !hosted_on_platform?
URI.join(asset_host, URI.parse(image[:url]).path).to_s
end
|
#width ⇒ Object
12
13
14
|
# File 'app/components/maglev/content/image.rb', line 12
def width
image[:width]
end
|