5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-22 20:36:21 +00:00
panel/app/javascript/controllers/file_preview_controller.js

20 lines
452 B
JavaScript
Raw Permalink Normal View History

2024-07-20 18:21:03 +00:00
import { Controller } from '@hotwired/stimulus'
import bsCustomFileInput from "bs-custom-file-input";
document.addEventListener("turbolinks:load", () => {
bsCustomFileInput.init();
});
export default class extends Controller {
static targets = ["preview", "input"];
connect() {
}
update(event = undefined) {
if (!this.hasPreviewTarget) return;
this.previewTarget.src = window.URL.createObjectURL(this.inputTarget.files[0])
}
}