kirtithorat / carrierwave-crop

Carrierwave extension to crop uploaded images using Jcrop plugin with preview.
MIT License
94 stars 58 forks source link

Add "only version(s)" and data html attributes for javascript #16

Open sunchess opened 9 years ago

sunchess commented 9 years ago

You can set versions where need to crop.

    #Version for ipad
    version :ipad_main do
      process crop: :image
    end

    #Set crop versions for example in _ipad.html.erb partial
    <%= f.cropbox :avatar, only: :ipad_main %>

    #Version for android
    version :android_main do
      process crop: :image
    end

    #Set crop versions for example in _andtoid.html.erb partial
    <%= f.cropbox :avatar, only: :android_main %>

    #or both
    <%= f.cropbox :avatar, only: [:ipad_main, :android_main] %>

If you need to html data attributes you can set data option

    <%= f.cropbox :avatar, data: {width: 1024, height: 768} %>

    #and you can use it in javascript