{% with id=widget.attrs.id %}
{ p = p.trim(); if (p.endsWith('/*')) return file.type.startsWith(p.replace('/*', '/')); if (p.startsWith('.')) return file.name.toLowerCase().endsWith(p.toLowerCase()); return file.type === p; }); }, loadPreview(file) { if (!file || !file.type.startsWith('image/')) return; const reader = new FileReader(); reader.onload = (e) => this.preview = e.target.result; reader.readAsDataURL(file); }, handleDrop(e) { this.dragging = false; this.error = ''; const file = e.dataTransfer.files[0]; if (!file) return; if (!this.isAccepted(file)) { this.error = 'File type not accepted'; return; } if (this.maxSize && file.size > this.maxSize) { this.error = 'File too large'; return; } this.$refs.input.files = e.dataTransfer.files; this.loadPreview(file); }, handleChange(e) { this.error = ''; const file = e.target.files[0]; if (!file) { this.preview = null; return; } if (this.maxSize && file.size > this.maxSize) { this.error = 'File too large'; e.target.value = ''; return; } this.loadPreview(file); }, clear() { this.preview = null; this.error = ''; this.$refs.input.value = ''; } }" @dragover.prevent="dragging = true" @dragleave.prevent="dragging = false" @drop.prevent="handleDrop($event)">

Drop an image or browse

{% if widget.accept_display or widget.max_size_display %}

{% if widget.accept_display %}{{ widget.accept_display }}{% endif %}{% if widget.accept_display and widget.max_size_display %} · {% endif %}{% if widget.max_size_display %}Max {{ widget.max_size_display }}{% endif %}

{% endif %}

{% if widget.accept_display or widget.max_size_display %}

{% if widget.accept_display %}{{ widget.accept_display }}{% endif %}{% if widget.accept_display and widget.max_size_display %} · {% endif %}{% if widget.max_size_display %}Max {{ widget.max_size_display }}{% endif %}

{% endif %}
{% endwith %}