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
22
23
24
|
# File 'app/components/maglev/content/image.rb', line 22
def alt_text
image[:alt_text]
end
|
#height ⇒ Object
18
19
20
|
# File 'app/components/maglev/content/image.rb', line 18
def height
image[:height]
end
|
#tag(view_context, options = {}) ⇒ Object
30
31
32
33
34
35
36
37
38
|
# File 'app/components/maglev/content/image.rb', line 30
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
26
27
28
|
# File 'app/components/maglev/content/image.rb', line 26
def to_s
url
end
|
#url ⇒ Object
8
9
10
11
12
|
# File 'app/components/maglev/content/image.rb', line 8
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
14
15
16
|
# File 'app/components/maglev/content/image.rb', line 14
def width
image[:width]
end
|