<commit_before># RailsAdmin Jcrop Plugin

## Image cropping made easy! ##

1. Add it to your Gemfile and run `bundle install`:

        gem 'rails_admin'
        # Because rails_admin_jcrop autoload modules by checking plugins you use, it's
        # recommended to require it explictly before rails_admin_jcrop
        # e.g. if you use carrierwave
        # gem 'carrierwave', :require => 'carrierwave'
        gem 'rails_admin_jcrop' #, git: 'git://github.com/janx/rails_admin_jcrop.git'

2. Configure your model field to use Jcrop:

        # RAILS_ROOT/config/initializers/rails_admin.rb
        config.model User do
          configure :avatar, :jcrop

          # Below is optional
          edit do
            field :avatar do
              jcrop_options aspectRatio: 500.0/320.0
            end
          end
        end

3. If you use Paperclip, you need to do nothing here, rails_admin_jcrop will append RailsAdminJcropper processor to your attachment automatically. If CarrierWave is used, please invoke  :rails_admin_crop in your uploader:

        class AvatarUploader < CarrierWave::Uploader::Base

          version :thumb do
            process :rails_admin_crop
            process :resize_to_fill: [500,320]
          end

        end

4. Done! Click the image on your RailsAdmin model edit page and enjoy cropping!
![Cropping Screenshot](https://github.com/janx/rails_admin_jcrop/raw/master/screenshots/example.png)

### Notice ###

`rails_admin_jcrop >= 1.0.0` works with `rails_admin ~> 0.3.x`.

For older rails_admin, use rails_admin_jcrop 0.3.1.

## Field Options ##

### jcrop_options ###

You can pass any Jcrop plugin allowed options here, for example, use `aspectRatio` to fix the ratio of selection box:

            field :avatar do<commit_msg>fix typo<commit_after># RailsAdmin Jcrop Plugin

## Image cropping made easy! ##

1. Add it to your Gemfile and run `bundle install`:

        gem 'rails_admin'
        # Because rails_admin_jcrop autoload modules by checking plugins you use, it's
        # recommended to require it explictly before rails_admin_jcrop
        # e.g. if you use carrierwave
        # gem 'carrierwave', :require => 'carrierwave'
        gem 'rails_admin_jcrop' #, git: 'git://github.com/janx/rails_admin_jcrop.git'

2. Configure your model field to use Jcrop:

        # RAILS_ROOT/config/initializers/rails_admin.rb
        config.model User do
          configure :avatar, :jcrop

          # Below is optional
          edit do
            field :avatar do
              jcrop_options aspectRatio: 500.0/320.0
            end
          end
        end

3. If you use Paperclip, you need to do nothing here, rails_admin_jcrop will append RailsAdminJcropper processor to your attachment automatically. If CarrierWave is used, please invoke  :rails_admin_crop in your uploader:

        class AvatarUploader < CarrierWave::Uploader::Base

          version :thumb do
            process :rails_admin_crop
            process :resize_to_fill: [500,320]
          end

        end

4. Done! Click the image on your RailsAdmin model edit page and enjoy cropping!
![Cropping Screenshot](https://github.com/janx/rails_admin_jcrop/raw/master/screenshots/example.png)

### Notice ###

`rails_admin_jcrop >= 1.0.0` works with `rails_admin ~> 0.3.x`.

For older rails_admin, use rails_admin_jcrop 0.2.1.

## Field Options ##

### jcrop_options ###

You can pass any Jcrop plugin allowed options here, for example, use `aspectRatio` to fix the ratio of selection box:

            field :avatar do
{'fraction_non_alphanumeric': 0.07842031029619181, 'fraction_numerical': 0.01466854724964739, 'mean_word_length': 2.7247899159663866, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3775540', 'n_tokens_mistral': 1155, 'n_tokens_neox': 1044, 'n_words': 354}