No commit activity in last 3 years
No release in over 3 years
More perfect decision for loading image in form with preview
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3
>= 0

Runtime

 Project Readme

AlterFormImages

More perfect decision for loading image in form with preview. This gem using several simple things that are bundled in small flexible plugin for Rails.

Installation

Add this line to your application's Gemfile:

gem 'alter_form_images'

And then execute:

$ bundle

Or install it yourself as:

$ gem install alter_form_images

Usage

For start using provided tweaks add require js in your application.js:

  //= require alter_form_images

Then add require css in your application.css:

  *= require alter_form_images

And now we need to do the last step with example situation: you has User model with avatar attachment and for setting it in form add follow lines of code:

  f.image_fields_for :avatar

You of course may do some configuration in this point:

  f.image_fields_for :avatar, {
    width: 100,                          # Width of preview image
    height: 100,                         # Height of preview image
    default_image: 'default_image.png',  # Url to default image
    preview_style: :original             # Style of image for preview in edit form
  }

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