forked from activeadmin/activeadmin
-
Notifications
You must be signed in to change notification settings - Fork 4
Showing an uploaded image in the form
dannynorman edited this page Mar 21, 2012
·
4 revisions
To show a preview of a form image, use the :hint form parameter, like so (thank to Greg Tangey for this on the mailing list:
f.inputs "Attachment", :multipart => true do
f.input :cover_page, :as => :file, :hint => f.template.image_tag(f.object.image.url)
f.input :cover_page_cache, :as => :hidden
end
Of course you can still do all the processing you are used to from PaperClip or CarrierWave:
f.inputs "Attachment", :multipart => true do
f.input :cover_page, :as => :file, :hint => f.template.image_tag(f.object.image.url(:thumb))
f.input :cover_page_cache, :as => :hidden
end
Remember the _cache input field to get previews in non-saved records with e.g. CarrierWave. See Ryans Railscast on CarrierWave for more information