No release in over 3 years
Low commit activity in last 3 years
Rails Engine built on top of Paperclip gem to add extra attributes to your attachments.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

~> 0.3.0
>= 4.2.0, ~> 4.2
>= 4.2.0, ~> 4.2
 Project Readme

DEPRECATED - no longer actively maintained

Paperclip Attributes Gem Version Build Status Coverage Status

Rails Engine built on top of Paperclip gem to add attributes, as columns in your models, related to your attachments.

Paperclip Attributes is no longer maintained.

  • We will leave the Issues open as a discussion forum only.
  • We do not guarantee a response from us in the Issues.
  • We are no longer accepting pull requests.

Installation

Add to your Gemfile:

gem "paperclip_attributes"
bundle install

Usage

To add new attributes, you need to run the following generator:

rails g paperclip_attributes Model attachment recipe1 recipe2
  • Model: is the Active Record model containing the attachment you want to add attributes.
  • attachment: is the paperclip's attachment name on given model.
  • recipes (recipe1 recipe2): is a list of recipes to extend the attachment. A recipe represents one or more attributes related to the attachment param. You can see a full list of recipes on the section below.

The generator, will only create migrations to extend your attachments. So, after run it, you need to do:

rake db:migrate

Then, to enable the functionality in your model, you need to add the recipes to the attachment definition:

class MyModel < ActiveRecord::Base
  has_attached_file :attachment, attributes: [:recipe1, :recipe2]
end

That's it!

The process to extract attributes will be done on before_save callback.

Example

rails g paperclip_attributes User avatar dimensions color

In User model:

class User < ActiveRecord::Base
  has_attached_file :avatar, attributes: [:dimensions, :color]
end

Then, with an User instance, you'll be able to do something like this:

user = User.new
user.avatar = some_file
user.save!

user.avatar_height #=> 200
user.avatar_width #=> 400
user.avatar_dominant_color #=> "#FF9900"

Recipes

For images:

dimensions:

  • [attachment]_width: the original width of the image.
  • [attachment]_height: the original height of the image.

color:

  • [attachment]_dominant_color: the predominant color of the image.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Credits

Thank you contributors!

Platanus

Paperclip Attributes is maintained by platanus.

License

Paperclip Attributes is © 2016 platanus, spa. It is free software and may be redistributed under the terms specified in the LICENSE file.