Sha256: 9f2869e2ee45b1658e83e8cf94b12949cfcb136f713aec5662f110a737a2fe93

Contents?: true

Size: 896 Bytes

Versions: 1

Compression:

Stored size: 896 Bytes

Contents

require 'image_optim'

class ImageOptim
  class Railtie < Rails::Railtie
    initializer 'image_optim.initializer' do |app|
      if app.config.assets.compress && app.config.assets.image_optim != false
        image_optim = if app.config.assets.image_optim == true
                        ImageOptim.new
                      else
                        ImageOptim.new(app.config.assets.image_optim || {})
                      end

        processor = proc do |context, data|
          image_optim.optimize_image_data(data) || data
        end

        app.assets.register_preprocessor 'image/gif', :image_optim, &processor
        app.assets.register_preprocessor 'image/jpeg', :image_optim, &processor
        app.assets.register_preprocessor 'image/png', :image_optim, &processor
        app.assets.register_preprocessor 'image/svg+xml', :image_optim, &processor
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
image_optim-0.11.0 lib/image_optim/railtie.rb