Image Upload Preview

Multi-image upload with thumbnail preview.

python 9 params

Preview

    Usage

    views.py
    python
    from djust import LiveView
    from djust.components import ImageUploadPreview
    
    
    class MyView(LiveView):
        template_name = "my_template.html"
    
        def mount(self, request, **kwargs):
            self.component = ImageUploadPreview()
    my_template.html
    django
    {{ component }}

    Needs its script on the page: <script src="{% static 'djust_components/image-upload-preview.js' %}"></script>. djust ships it; without it the markup renders but does not update in the browser.

    Parameters

    NameTypeDefaultDescription
    namestr'images'Form field name.
    maxint5Maximum number of images (selected plus ``previews``).
    eventstr | None — renames the eventNoneEvent fired when a selection has uploaded (see above). Nothing is sent unless you name one.
    acceptstr'image/*'Accepted MIME types (default: image/*).
    previewslist | NoneNoneList of existing preview URLs.
    custom_classstr''Additional CSS classes.
    uploadstr | NoneNoneUpload slot name (``allow_upload``); ``None`` is a plain input.
    max_sizeint0Largest file in bytes to pre-check (``0``: no pre-check).
    **kwargs— passed to `Component.__init__`: `id=` sets `component.id`, and any other keyword is kept as state——
    Source & styles
    FilePathNotes
    moduledjust.components.components.image_upload_previewSubclass it, or pass custom_class, to change how it renders.
    cssdjust_components/components.cssDefines 8 of this component's classes at line 2400, 2401, 2403, 2404, 2405, 2408, 2409, 2423. Override those rules, or the custom properties they read, in a stylesheet loaded after it.