Builder struct for adding media to a model.
This module provides a fluent API for configuring media before it is persisted to storage and the database.
You typically won't use this module directly - instead use the
functions in PhxMediaLibrary which delegate here.
Summary
Functions
Create a new MediaAdder for the given model and source.
Finalize and persist the media.
Set a custom filename.
Set custom properties.
Enable responsive image generation.
Disable automatic metadata extraction for this media.
Types
Functions
@spec new(Ecto.Schema.t(), source()) :: t()
Create a new MediaAdder for the given model and source.
@spec to_collection(t(), atom(), keyword()) :: {:ok, PhxMediaLibrary.Media.t()} | {:error, term()}
Finalize and persist the media.
Set a custom filename.
Set custom properties.
Enable responsive image generation.
Disable automatic metadata extraction for this media.
By default, PhxMediaLibrary extracts metadata (dimensions, EXIF, etc.) from uploaded files. Use this to skip extraction for a specific upload.
Examples
post
|> PhxMediaLibrary.add(upload)
|> PhxMediaLibrary.without_metadata()
|> PhxMediaLibrary.to_collection(:images)