Sha256: df4fb56234a38027c3d6b3bd6882a841235ba713b89063a2419840dd7b63dacc

Contents?: true

Size: 455 Bytes

Versions: 3

Compression:

Stored size: 455 Bytes

Contents

module Paperclip
  class Attachment
    extend ActiveSupport::Memoizable

    def to_liquid
      {}.tap do |h|
        all_styles = self.styles.keys + ['original']
        all_styles.each do |style|
          g = Paperclip::Geometry.from_file(self.path(style)) rescue nil
          h[style.to_s] = {'width' => g.width.to_i, 'height' => g.height.to_i, 'url' => self.url(style)} unless g.nil?
        end
      end
    end
    memoize :to_liquid
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
liquid_cms-0.2.1.1 app/liquid/cms_paperclip_extension.rb
liquid_cms-0.3.1.0 app/liquid/cms_paperclip_extension.rb
liquid_cms-0.2.1.0 app/liquid/cms_paperclip_extension.rb