Class: Jekyll::Assets::Default::Img

Inherits:
Jekyll::Assets::Default show all
Defined in:
lib/jekyll/assets/plugins/html/defaults/img.rb

Instance Attribute Summary

Attributes inherited from Extensible

#args, #asset, #ctx, #env, #jekyll

Instance Method Summary collapse

Methods inherited from Jekyll::Assets::Default

#config, get, #run, set, set_static, static

Methods inherited from Extensible

for?, for_args?, for_type?, inherited, #initialize, internal!, internal?, requirements

Constructor Details

This class inherits a constructor from Jekyll::Assets::Extensible

Instance Method Details

#integrity?Boolean

Returns:

  • (Boolean)


46
47
48
49
# File 'lib/jekyll/assets/plugins/html/defaults/img.rb', line 46

def integrity?
  config[:integrity] && !@asset.is_a?(Url) &&
    !@args.key?(:integrity)
end

#set_heightObject



22
23
24
25
26
# File 'lib/jekyll/assets/plugins/html/defaults/img.rb', line 22

def set_height
  unless args.key?(:height) || !config[:height]
    args[:height] = "auto"
  end
end

#set_integrityObject



37
38
39
40
41
42
43
# File 'lib/jekyll/assets/plugins/html/defaults/img.rb', line 37

def set_integrity
  return unless integrity?
  @args[:integrity] = @asset.integrity
  unless @args.key?(:crossorigin)
    @args[:crossorigin] = "anonymous"
  end
end

#set_srcObject



29
30
31
32
33
34
# File 'lib/jekyll/assets/plugins/html/defaults/img.rb', line 29

def set_src
  dpath = @asset.digest_path
  return @args[:src] = @asset.url if @asset.is_a?(Url)
  return @args[:src] = @env.prefix_url(dpath) unless @args[:inline]
  @args[:src] = @asset.data_uri
end

#set_widthObject



15
16
17
18
19
# File 'lib/jekyll/assets/plugins/html/defaults/img.rb', line 15

def set_width
  unless args.key?(:width) || !config[:width]
    args[:width] = "100%"
  end
end