Socket
Socket
Sign inDemoInstall

active_storage_preview

Package Overview
Dependencies
139
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    active_storage_preview

Simple Active Storage script with direct upload and image preview.


Version published
Weekly downloads
32
decreased by-45.76%
Maintainers
1
Created
Weekly downloads
 

Changelog

Source

v0.0.1

  • Direct Upload;
  • Image Preview;

Readme

Source

Active Storage Preview

Build Status NPM Version Dependency Dev Dependency Code Climate Support

Options

AttributeDefaultDescription
attribute'src'The attribute that will receive the image preview
formundefinedThe form that contain the file uplod field
targetundefinedThe target for the image(s)
uploadButtonundefinedThe button to trigger the upload file selection
uploadFieldundefinedThe file field

Usage

For Image

When using single image, sets the target directly on image. Image will receive the src.

<img data-target>

<form data-form enctype="multipart/form-data">
  <input data-upload-field type="file">

  <a data-upload-button href="javascript:void(0)">Select Image</a>
</form>
new ActiveStoragePreview({
  form:         document.querySelector('[data-form]'),
  target:       document.querySelector('[data-target]'),
  uploadButton: document.querySelector('[data-upload-button]'),
  uploadField:  document.querySelector('[data-upload-field]'),
}).create();

For Image used on background

When using single image on background, like cover, sets the target directly on image. Image will receive the background-image. You must set attribute option as style.

<div data-target></div>

<form data-form enctype="multipart/form-data">
  <input data-upload-field multiple="multiple" type="file">

  <a data-upload-button href="javascript:void(0)">Select Image</a>
</form>
new ActiveStoragePreview({
  attribute:    'style',
  form:         document.querySelector('[data-form]'),
  target:       document.querySelector('[data-target]'),
  uploadButton: document.querySelector('[data-upload-button]'),
  uploadField:  document.querySelector('[data-upload-field]'),
}).create();

For Images

When using multiple images, sets the target on a wrapper. Images will be appended. Do not forget the multiple attribute on field. :)

<div data-target></div>

<form data-form enctype="multipart/form-data">
  <input data-upload-field multiple="multiple" type="file">

  <a data-upload-button href="javascript:void(0)">Select Image</a>
</form>
new ActiveStoragePreview({
  form:         document.querySelector('[data-form]'),
  target:       document.querySelector('[data-target]'),
  uploadButton: document.querySelector('[data-upload-button]'),
  uploadField:  document.querySelector('[data-upload-field]'),
}).create();

Keywords

FAQs

Last updated on 11 Aug 2020

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc