Project

crimagify

0.0
No commit activity in last 3 years
No release in over 3 years
Manage your model images with RMagick and CarrierWave
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

~> 0.8.0
~> 3.2.12
~> 2.13.1
 Project Readme

Manage your model images with RMagick and CarrierWave.

Installation¶ ↑

  1. Add to your Gemfile: gem 'crimagify'

  2. Run Bundle

  3. Execute: rails generate crimagify:install

  4. Run migrations: rake db:migrate

  5. Run seeds: rake db:seed


Implementation¶ ↑

Add to your routes.rb: mount Crimagify::Engine => "/crimagify", :as => "crimagify"

Add to your model:

...
extend Crimagify::DinamicImageMethods
has_many :crimagify_images, :as => :parent, :dependent => :destroy, :class_name => Crimagify::Image
build_methods_images
...

Add to your controller:

...
#For Action Create:
if @object.save
	Crimagify::ImageFunctions::create_new_images(@object, params)
end
...

...
#For Action Update:
id @object.update_attributes(params[:object])
	Crimagify::ImageFunctions::update_images(@object, params)
end
...

Add to application.js://= require crimagify/application

Edit the file generated for the gem: config/crimagify_versions.yml, with the specific format mantaining the same ratio for all versions in each blocks, adding models that use images:

User:
    imgA:
        user:
            width: 100
            height: 100
        big:
            width: 500
            height: 500
    imgB:
        big:
            width: 800
            height: 500
        small:
            width: 400
            height: 250
Product:
    imgA:
        big:
            width: 600
            height: 300

Add to your form view:

<%= form_for(@object) do |f| %>
...
<%= images_id(@object) %>
<%= image_cropper(@object, { image_name: "imgA", ratio: :big}) %>   #The attributes "imgA" and :big or :small are defined 
<%= image_cropper(@object, { image_name: "imgB", ratio: :small}) %> #into file config/crimagify_versions.yml generated for the gem
...
<% end %>