Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
active_storage_preview
Advanced tools
Changelog
v0.1.0
Readme
Simple Active Storage script with Direct Upload and Image Preview
Attribute | Default | Description |
---|---|---|
attribute | 'src' | The attribute that will receive the image preview |
form | undefined | The form that contain the file uplod field |
target | undefined | The target for the image(s) |
template | undefined | Callback used to build the preview element |
uploadButton | undefined | The button to trigger the upload file selection |
uploadField | undefined | The file field |
Appends the template on target.
<div data-target></div>
<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]'),
template: function(src, _id, _file) { return '<img src="' + src + '">' },
uploadButton: document.querySelector('[data-upload-button]'),
uploadField: document.querySelector('[data-upload-field]'),
}).create();
Change the src
attribute of image ignoring the template content.
<div data-target>
<img src="pixel.png">
</div>
<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]'),
template: function(src, _id, _file) { return '<img src="' + src + '">' },
uploadButton: document.querySelector('[data-upload-button]'),
uploadField: document.querySelector('[data-upload-field]'),
}).create();
Ignores template and changes the property background-image
of the style
tag of the target. To enable it, you must set `attribute: 'style'.
<div data-target></div>
<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({
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();
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 Images</a>
</form>
new ActiveStoragePreview({
form: document.querySelector('[data-form]'),
target: document.querySelector('[data-target]'),
template: function(src, _id, _file) { return '<img src="' + src + '">' },
uploadButton: document.querySelector('[data-upload-button]'),
uploadField: document.querySelector('[data-upload-field]'),
}).create();
FAQs
Simple Active Storage script with Direct Upload and Image Preview
The npm package active_storage_preview receives a total of 11 weekly downloads. As such, active_storage_preview popularity was classified as not popular.
We found that active_storage_preview 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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.