![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
active_storage_preview
Advanced tools
Simple Active Storage script with Direct Upload and Image Preview
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 0 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
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.