百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
S

simple_form_fancy_uploads

> 编程语言
开源

使用 simple_form 自定义输入,在文件上传时获取图像/链接预览。

163 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

使用 simple_form 自定义输入,在文件上传时获取图像/链接预览。

SimpleForm fancy uploads

A set of simple_form (~> 4.1) custom inputs to get image previews or a link to uploaded file.

This gem uses the simple_form ability to write your own form tags (check the simple_form-bootstrap example). In 90% of cases, you need some kind of preview when it comes to uploaded files (avatar, images, docs, etc..), why should I write the same markup each time?

What you get

There're only two new file inputs:

  • ImagePreview: guess what? when you edit an entry that contains an uploaded image, it will be shown (how many times did you this in a CMS?)
  • AttachmentPreview: this is a generic upload field, it will show a direct link to the file, so you can check what was uploaded.

How it works

Install

Simply add gem 'simple_form_fancy_uploads' to your Gemfile and run bundle install

Usage

Here's a basic example, as you can see, it's just a matter of specify the input as :image_preview or :attachment_preview. If using :image_preview, you can also specify a :preview_version => :some_version_name inside the :input_html Hash. This will let you to show a custom version generated with Carrierwave. Nice, isn't it?

If you need to fallback on Carrierwave's #default_url method to show a default image defined in your upload class, set :use_default_url => true in the options hash.

erb

  
  

  
  

If you want, you can pass the preview_url to the image on the input_html options. This might be useful when you don't have a model binded to the form.

erb

  

Dependencies

To get it work, you need:

  • simple_form ~> 4.1 (repetita iuvant)
  • carrierwave actually it's the most opinionated gem for uploads (thank you paperclip for the good times, but you know... life goes on)
  • ruby 2.2.2+

Testing

  • clone this repo
  • run bundle install
  • run rspec spec

Contributions & Bugs

  • the easy way: go to issues page and blame me.
  • the hard way: repeat the above points, then show your power and send a pull request.

License

Copyright (c) 2014 Andrea Pavoni http://andreapavoni.com

Issues· 13 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Ruby

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言