module Shrine::Plugins::Blurhash
Constants
- LOG_SUBSCRIBER
Public Class Methods
configure(uploader, log_subscriber: LOG_SUBSCRIBER, **opts)
click to toggle source
# File lib/shrine/plugins/blurhash.rb, line 15 def self.configure(uploader, log_subscriber: LOG_SUBSCRIBER, **opts) uploader.opts[:blurhash] ||= { extractor: :ruby_vips, on_error: :warn, auto_extraction: true, resize_to: 100, components: [4, 3], } uploader.opts[:blurhash].merge!(opts) # resolve error strategy uploader.opts[:blurhash][:on_error] = case uploader.opts[:blurhash][:on_error] when :fail then ->(error) { raise error } when :warn then ->(error) { Shrine.warn "Error occurred when attempting to extract blurhash: #{error.inspect}" } when :ignore then ->(error) {} else uploader.opts[:blurhash][:on_error] end uploader.subscribe(:blurhash, &log_subscriber) if uploader.respond_to?(:subscribe) end