5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-22 20:56:22 +00:00
panel/app/javascript/etc/image_preview.js

11 lines
368 B
JavaScript

document.addEventListener('turbolinks:load', () => {
document.querySelectorAll('input[type=file]').forEach(file => {
if (!file.dataset.preview) return
file.addEventListener('change', event => {
if (file.files.length === 0) return
document.querySelector('#' + file.dataset.preview).src = window.URL.createObjectURL(file.files[0])
})
})
})