PhiaUi.Components.ImageGalleryUpload (phia_ui v0.1.17)

Copy Markdown View Source

Multi-image upload with a grid thumbnail gallery.

Provides image_gallery_upload/1 — a max_entries-aware upload zone that renders selected images as live thumbnails in a responsive grid. Each thumbnail shows a remove button. An "Add more" cell is rendered while the entry limit has not been reached.

Requirements

The parent LiveView must configure the upload with allow_upload/3:

def mount(_params, _session, socket) do
  {:ok,
   socket
   |> allow_upload(:gallery,
     accept: ~w(.jpg .jpeg .png .webp),
     max_entries: 6,
     max_file_size: 10_000_000
   )}
end

Basic usage

<.image_gallery_upload
  upload={@uploads.gallery}
  label="Product images"
  on_cancel="cancel_upload"
/>

Handling cancel

def handle_event("cancel_upload", %{"ref" => ref}, socket) do
  {:noreply, cancel_upload(socket, :gallery, ref)}
end

Summary

Functions

Renders a grid of image thumbnails with an "Add more" cell.

Functions