Class: Jekyll::Assets::Plugins::ImageOptim

Inherits:
Jekyll::Assets::Proxy show all
Defined in:
lib/jekyll/assets/plugins/proxy/optim.rb

Defined Under Namespace

Classes: MultiplePredefinedPresetsSpecified, UnknownPresetError

Instance Attribute Summary

Attributes inherited from Jekyll::Assets::Proxy

#file

Attributes inherited from Extensible

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

Instance Method Summary collapse

Methods inherited from Jekyll::Assets::Proxy

args_key, copy, digest, #initialize, keys, proxies_for, proxy

Methods inherited from Extensible

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

Constructor Details

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

Instance Method Details

#processObject

Raises:

  • (UnknownPreset)


27
28
29
30
31
32
33
34
35
# File 'lib/jekyll/assets/plugins/proxy/optim.rb', line 27

def process
  # rubocop:disable Metrics/LineLength
  optimc = @env.asset_config[:plugins][:img][:optim]
  preset = @args[:optim] == true ? :jekyll : @args[:optim].to_sym
  raise UnknownPreset, preset if preset != :jekyll && !optimc.key?(preset)
  optim = ::ImageOptim.new(optimc[preset] || {})
  optim.optimize_image!(@file)
  @file
end