Module: Shrine::Plugins::Thumbhash

Defined in:
lib/shrine/plugins/thumbhash.rb,
lib/shrine/plugins/thumbhash/image.rb,
lib/shrine/plugins/thumbhash/version.rb,
lib/shrine/plugins/thumbhash/image_loader/ruby_vips.rb,
lib/shrine/plugins/thumbhash/image_loader/mini_magick.rb

Overview

:nodoc:

Defined Under Namespace

Modules: ClassMethods, FileMethods, ImageLoader, InstanceMethods Classes: Image

Constant Summary collapse

IMAGE_LOADER_CHOICES =
[
  :ruby_vips,
  :mini_magick
].freeze
DEFAULT_OPTIONS =
{
  padding: true,
  image_loader: :ruby_vips
}.freeze
VERSION =
"0.2.1"

Class Method Summary collapse

Class Method Details

.configure(uploader, **opts) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/shrine/plugins/thumbhash.rb', line 18

def self.configure(uploader, **opts)
  uploader.opts[:thumbhash] ||= DEFAULT_OPTIONS.dup
  uploader.opts[:thumbhash].merge!(opts)
  image_loader_option = uploader.opts[:thumbhash][:image_loader]

  return unless IMAGE_LOADER_CHOICES.include?(image_loader_option)

  configure_image_loader(uploader.opts[:thumbhash])
end

.configure_image_loader(opts) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'lib/shrine/plugins/thumbhash.rb', line 28

def self.configure_image_loader(opts)
  case opts[:image_loader]
  when :mini_magick
    require_relative "thumbhash/image_loader/mini_magick"
    opts[:image_loader] = Shrine::Plugins::Thumbhash::ImageLoader::MiniMagick
  else
    require_relative "thumbhash/image_loader/ruby_vips"
    opts[:image_loader] = Shrine::Plugins::Thumbhash::ImageLoader::RubyVips
  end
end