Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
simple_form_fancy_uploads
Advanced tools
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?
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.Simply add gem 'simple_form_fancy_uploads'
to your Gemfile
and run bundle install
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.
<%= simple_form_for @some_model do |f| %>
<!-- we specify that this is an image form upload input, and we want to show the 'thumb' version
of the carrierwave upload to not break our layout with a non-resized image -->
<%= f.input :some_image_field, as: :image_preview, input_html: {preview_version: :thumb} %>
<!-- here's a *normal* attachment. with this input, a link to the filename will be shown
if there's an uploaded file -->
<%= f.input :some_attachment_field, as: :attachment_preview %>
<% end %>
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.
<%= simple_form_for :user do |f| %>
<%= f.input :image, as: :image_preview, input_html: { preview_url: image_url } %>
<% end %>
To get it work, you need:
bundle install
rspec spec
Copyright (c) 2014 Andrea Pavoni http://andreapavoni.com
FAQs
Unknown package
We found that simple_form_fancy_uploads demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.