Class: Jekyll::UJImageTag
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- Jekyll::UJImageTag
- Defined in:
- lib/tags/image.rb
Instance Method Summary collapse
-
#initialize(tag_name, markup, tokens) ⇒ UJImageTag
constructor
A new instance of UJImageTag.
- #render(context) ⇒ Object
Constructor Details
#initialize(tag_name, markup, tokens) ⇒ UJImageTag
Returns a new instance of UJImageTag.
6 7 8 9 |
# File 'lib/tags/image.rb', line 6 def initialize(tag_name, markup, tokens) super @markup = markup.strip end |
Instance Method Details
#render(context) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/tags/image.rb', line 11 def render(context) # Parse arguments args = parse_arguments(@markup) src_input = args[0] = (args[1..-1]) # Resolve source path src = resolve_variable(context, src_input) return '' unless src # Check if this is an external URL is_external = !!(src =~ /^https?:\/\//) if is_external # For external URLs, just create a simple responsive img tag build_external_image(src, ) else # Extract file extension extension = File.extname(src) src_path = src.chomp(extension) # Determine max width max_width = ['max_width'] || ['max-width'] || false max_width = max_width.to_s if max_width # Build picture element for local images build_picture_element(src, src_path, extension, max_width, ) end end |