import {Controller} from '@hotwired/stimulus' export default class extends Controller { static values = {url: String, alt: String} static classes = ['image'] connect() { const img = new Image() img.onload = () => { img.classList.add(...this.imageClasses) this.element.innerHTML = '' this.element.appendChild(img) } img.alt = this.altValue img.src = this.urlValue } }