Sha256: ed8805b795ed4a7c1095daa7fc4651fc55008bc083d362e41a32b210acdc5aa4
Contents?: true
Size: 1.47 KB
Versions: 4
Compression:
Stored size: 1.47 KB
Contents
=Paperclip Meta {<img src="https://secure.travis-ci.org/y8/paperclip-meta.png" />}[http://travis-ci.org/y8/paperclip-meta] Simple gem to let paperclip play nice with thumbnails width, height and size. Paperclip Meta will get image dimensions right after post_process_styles using paperclips own Geometry.from_file. This should make paperclip-meta storage independent. ==Quick Start Add paperclip-meta to Gemfile: gem 'paperclip-meta' Create migration: class AddMetaToAvatar < ActiveRecord::Migration def self.up add_column :users, :avatar_meta, :text end def self.down remove_column :users, :avatar_meta end end Rebuild all thumbnails to fill meta column if you already have some attachments. Now you can use meta-magic: <%= image_tag @user.avatar.url, :size => @user.avatar.image_size %> <%= image_tag @user.avatar.url(:medium), :size => @user.avatar.image_size(:medium) %> <%= image_tag @user.avatar.url(:thumb), :size => @user.avatar.image_size(:thumb) %> ==Internals Meta column is simple hash: :style => { :width => 100, :height => 100, :size => 42000 } This hash will be marshaled and base64 encoded before writing to model attribute. Meta methods provided: - width `@user.avatar.width(:thumb)` - height `@user.avatar.height(:medium)` - size `@user.avatar.size` You can pass thumbnail style to all these methods. If style not passed, default_style will be used. ==TODO * It will be nice to write some tests. :D
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
paperclip-meta-0.4.3 | README.rdoc |
paperclip-meta-0.4.2 | README.rdoc |
paperclip-meta-0.4.1 | README.rdoc |
paperclip-meta-0.4.0 | README.rdoc |