Module: Openseadragon::OpenseadragonHelper
- Defined in:
- app/helpers/openseadragon/openseadragon_helper.rb
Instance Method Summary collapse
-
#openseadragon_picture_tag(*sources) ⇒ Object
Generate a <picture> tag ready to be parsed by the openseadragon/rails javascript and transformed into an openseadragon viewer.
-
#picture_tag(*sources) ⇒ Object
Generate a <picture> tag containing the given sources.
Instance Method Details
#openseadragon_picture_tag(*sources) ⇒ Object
Generate a <picture> tag ready to be parsed by the openseadragon/rails javascript and transformed into an openseadragon viewer. Openseadragon tile source options are passed as a JSON encoded hash on the data-openseadragon attribute.
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'app/helpers/openseadragon/openseadragon_helper.rb', line 46 def openseadragon_picture_tag(*sources) = sources..symbolize_keys = sources..symbolize_keys sources.flatten! tile_sources = sources.map { |thing| extract_openseadragon_picture_tilesource(thing) } [:data] ||= {} [:data][:openseadragon] = osd_asset_defaults.merge([:data][:openseadragon] || {}).to_json picture_tag [tile_sources], { media: 'openseadragon' }.merge(), end |
#picture_tag(*sources) ⇒ Object
Generate a <picture> tag containing the given sources. A source can be a simple string, or a hash with the key for the value of the src attribute and the value as the arguments for the tag options.
The last hash is intepreted as optional arguments for the <picture> tag. The second to last hash is optional arguments to all <source> tags.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/helpers/openseadragon/openseadragon_helper.rb', line 16 def picture_tag *sources = sources..symbolize_keys = sources..symbolize_keys sources.flatten! content_tag :picture, do safe_join(sources.map do |source| = if source.is_a? Hash src, = source.first ||= {} .merge(.merge(src: src)) else .merge(src: source) end yield if block_given? tag :source, end) end end |