Configuration helpers for PhxMediaLibrary.
Summary
Functions
Get the async processor module.
Check if blurhash generation is enabled.
Get the default storage disk name.
Get configuration for a specific disk.
Return the global base URL where PhxMediaLibrary.Plug.MediaDownload is
mounted.
Get the image processor module.
Get the configured path generator module.
Get the configured Ecto repo.
Get the widths to generate for responsive images.
Get responsive images configuration.
Check if responsive images are enabled.
Return the global HMAC secret key used for signing local-disk URLs.
Get the storage adapter module for a disk.
Check if tiny placeholders should be generated.
Get the video processor module.
Functions
Get the async processor module.
Check if blurhash generation is enabled.
Blurhash requires the :image library to be available. Even when enabled
in config, this returns false if the library is not loaded.
Configuration
config :phx_media_library,
responsive_images: [
enabled: true,
blurhash: true # enable blurhash generation
]
Get the default storage disk name.
Get configuration for a specific disk.
Return the global base URL where PhxMediaLibrary.Plug.MediaDownload is
mounted.
This can be overridden per-disk via the :download_base_url key in the
disk config. Returns nil when not configured.
Configuration
config :phx_media_library, download_base_url: "/media"
Get the image processor module.
Defaults to PhxMediaLibrary.ImageProcessor.Image when the :image
library is available, otherwise falls back to
PhxMediaLibrary.ImageProcessor.Null which returns clear error messages
guiding the developer to install an image processing library.
Get the configured path generator module.
The path generator controls how storage paths are constructed for media
files and conversions. Any module that implements the
PhxMediaLibrary.PathGenerator behaviour can be used here.
Built-in generators:
PhxMediaLibrary.PathGenerator.Default—{type}/{id}/{uuid}/{filename}(default)PhxMediaLibrary.PathGenerator.Flat—{uuid}/{filename}PhxMediaLibrary.PathGenerator.DateBased—{year}/{month}/{day}/{type}/{id}/{uuid}/{filename}PhxMediaLibrary.PathGenerator.Tenant—{tenant_id}/{type}/{id}/{uuid}/{filename}
Configuration
config :phx_media_library,
path_generator: PhxMediaLibrary.PathGenerator.DateBased
Get the configured Ecto repo.
Get the widths to generate for responsive images.
Get responsive images configuration.
Check if responsive images are enabled.
Return the global HMAC secret key used for signing local-disk URLs.
This can be overridden per-disk via the :secret_key_base key in the disk
config. Returns nil when not configured.
Configuration
config :phx_media_library, secret_key_base: "long-random-secret"
Get the storage adapter module for a disk.
Check if tiny placeholders should be generated.
@spec video_processor() :: module()
Get the video processor module.
Defaults to PhxMediaLibrary.VideoProcessor.FFmpeg when both ffprobe
and ffmpeg executables are found on $PATH, otherwise falls back to
PhxMediaLibrary.VideoProcessor.Null.
When FFmpeg is available, video metadata (duration, dimensions, codec, fps) is extracted automatically on every video upload and a JPEG poster frame is stored alongside the video file.
Configuration
config :phx_media_library,
video_processor: MyApp.CustomVideoProcessor