PhxMediaLibrary.Config (PhxMediaLibrary v0.6.1)

Copy Markdown View Source

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

async_processor()

Get the async processor module.

blurhash_enabled?()

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
  ]

default_disk()

Get the default storage disk name.

disk_config(disk_name)

Get configuration for a specific disk.

download_base_url()

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"

image_processor()

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.

path_generator()

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:

Configuration

config :phx_media_library,
  path_generator: PhxMediaLibrary.PathGenerator.DateBased

repo()

Get the configured Ecto repo.

responsive_image_widths()

Get the widths to generate for responsive images.

responsive_images_config()

Get responsive images configuration.

responsive_images_enabled?()

Check if responsive images are enabled.

secret_key_base()

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"

storage_adapter(disk_name)

Get the storage adapter module for a disk.

tiny_placeholders_enabled?()

Check if tiny placeholders should be generated.

video_processor()

@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