Sha256: 74b4056b3fe59faea01917989fa036ffd75a6ccfa44b83cd7b171f3f5cd3c97d

Contents?: true

Size: 920 Bytes

Versions: 21

Compression:

Stored size: 920 Bytes

Contents

module Locomotive
  module Dragonfly

    def self.resize_url(source, resize_string)
      file = nil

      if source.is_a?(String) || source.is_a?(Hash) # simple string or theme asset
        source = source['url'] if source.is_a?(Hash)

        source.strip!

        if source =~ /^http/
          file = self.app.fetch_url(source)
        else
          file = self.app.fetch_file(File.join('public', source))
        end

      elsif source.respond_to?(:url) # carrierwave uploader
        if source.file.respond_to?(:url)
          file = self.app.fetch_url(source.url) # amazon s3, cloud files, ...etc
        else
          file = self.app.fetch_file(source.path)
        end

      else
        Locomotive.log :error, "Unable to resize on the fly: #{source.inspect}"
        return
      end

      file.process(:thumb, resize_string).url
    end

    def self.app
      ::Dragonfly[:images]
    end

  end
end

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
locomotive_cms-2.4.1 lib/locomotive/dragonfly.rb
locomotive_cms-2.4.0 lib/locomotive/dragonfly.rb
locomotive_cms-2.3.1 lib/locomotive/dragonfly.rb
locomotive_cms-2.3.0 lib/locomotive/dragonfly.rb
locomotive_cms-2.2.3 lib/locomotive/dragonfly.rb
locomotive_cms-2.2.2 lib/locomotive/dragonfly.rb
locomotive_cms-2.2.1 lib/locomotive/dragonfly.rb
locomotive_cms-2.2.0 lib/locomotive/dragonfly.rb
locomotive_cms-2.1.4 lib/locomotive/dragonfly.rb
locomotive_cms-2.1.3 lib/locomotive/dragonfly.rb
locomotive_cms-2.1.2 lib/locomotive/dragonfly.rb
locomotive_cms-2.1.1 lib/locomotive/dragonfly.rb
locomotive_cms-2.1.0 lib/locomotive/dragonfly.rb
tribeca_cms-0.1.1 lib/locomotive/dragonfly.rb
tribeca_cms-2.0.0.rc12 lib/locomotive/dragonfly.rb
locomotive_cms-2.0.0.rc12 lib/locomotive/dragonfly.rb
locomotive_cms-2.0.0.rc11 lib/locomotive/dragonfly.rb
locomotive_cms-2.0.0.rc10 lib/locomotive/dragonfly.rb
locomotive_cms-2.0.0.rc9 lib/locomotive/dragonfly.rb
locomotive_cms-2.0.0.rc8 lib/locomotive/dragonfly.rb