Class: EmbeddableContent::Images::ImgTagAttributes
- Inherits:
-
Object
- Object
- EmbeddableContent::Images::ImgTagAttributes
- Includes:
- Shared
- Defined in:
- app/services/embeddable_content/images/img_tag_attributes.rb
Instance Attribute Summary collapse
-
#node_processor ⇒ Object
readonly
Returns the value of attribute node_processor.
Instance Method Summary collapse
-
#height ⇒ Object
TODO: should this be abstracted?.
-
#initialize(node_processor) ⇒ ImgTagAttributes
constructor
A new instance of ImgTagAttributes.
- #src ⇒ Object
- #to_h ⇒ Object
- #width ⇒ Object
Constructor Details
#initialize(node_processor) ⇒ ImgTagAttributes
Returns a new instance of ImgTagAttributes.
13 14 15 |
# File 'app/services/embeddable_content/images/img_tag_attributes.rb', line 13 def initialize(node_processor) @node_processor = node_processor end |
Instance Attribute Details
#node_processor ⇒ Object (readonly)
Returns the value of attribute node_processor.
5 6 7 |
# File 'app/services/embeddable_content/images/img_tag_attributes.rb', line 5 def node_processor @node_processor end |
Instance Method Details
#height ⇒ Object
TODO: should this be abstracted?
43 44 45 46 47 48 |
# File 'app/services/embeddable_content/images/img_tag_attributes.rb', line 43 def height case target when :editable then height_for_editable_target when :cc, :kiddom, :qti, :schoology then image_height end end |
#src ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'app/services/embeddable_content/images/img_tag_attributes.rb', line 25 def src case target when :schoology, :cc, :kiddom then s3_url with_extension: false when :cms then cms_url when :editable then downloaded_file_url when :exported, :qti then s3_url with_extension: false when :print, :web then record.cdn_url end end |
#to_h ⇒ Object
17 18 19 20 21 22 23 |
# File 'app/services/embeddable_content/images/img_tag_attributes.rb', line 17 def to_h { alt: (alt_text), src: src, height: height, class: css_classes, width: width }.merge(aria_attrs).compact end |
#width ⇒ Object
35 36 37 38 39 40 |
# File 'app/services/embeddable_content/images/img_tag_attributes.rb', line 35 def width case target when :editable then width_for_editable_target when :cc, :kiddom, :qti, :schoology then image_width end end |