Validated, frozen configuration for Image.Plug.
Built once at compile/boot time by Image.Plug.init/1. The
request path then only reads struct fields.
Construct with new!/1. Direct struct construction is discouraged —
the validator enforces invariants such as "the provider module must
export parse/2" that are not visible from the struct shape alone.
Summary
Types
Signing configuration. nil disables signing entirely.
Functions
Validates a keyword list and returns an Image.Plug.Options
struct.
Types
Signing configuration. nil disables signing entirely.
When set, every request URL is verified against the configured
:keys list (HMAC-SHA256). When :required? is true, an
unsigned URL produces :signature_required. When :required? is
false, unsigned URLs pass through but a signed URL with an
invalid signature still 401s — defense in depth.
@type t() :: %Image.Plug.Options{ max_pixels: pos_integer(), on_error: Image.Plug.Pipeline.on_error(), provider: module(), provider_options: keyword(), request_timeout: pos_integer(), signing: signing_options(), source_resolver: module(), source_resolver_options: keyword(), telemetry_prefix: [atom(), ...], variant_store: module(), variant_store_options: keyword() }
Functions
Validates a keyword list and returns an Image.Plug.Options
struct.
Arguments
optionsis a keyword list. The:providerand:source_resolverkeys are required. Each must be a{module, options}tuple.
Options
:provider(required) —{module, options}for anImage.Plug.Providerimplementation.:source_resolver(required) —{module, options}for anImage.Plug.SourceResolverimplementation.:variant_store—{module, options}for anImage.Plug.VariantStoreimplementation. Defaults to{Image.Plug.VariantStore.ETS, []}.:on_error— error policy atom or{:status, code}tuple. Defaults to:auto.:max_pixels— soft upper bound on the output pixel count. Defaults to25_000_000.:request_timeout— total per-request budget in milliseconds. Defaults to10_000.:telemetry_prefix— list of atoms prepended to telemetry event names. Defaults to[:image_plug].
Returns
- An
Image.Plug.Optionsstruct.
Examples
iex> defmodule TestProv do
...> @behaviour Image.Plug.Provider
...> @impl true
...> def parse(_conn, _options), do: {:error, Image.Plug.Error.new(:not_implemented, "test")}
...> end
iex> defmodule TestRes do
...> @behaviour Image.Plug.SourceResolver
...> @impl true
...> def load(_source, _options), do: {:error, Image.Plug.Error.new(:not_implemented, "test")}
...> end
iex> options = Image.Plug.Options.new!(
...> provider: {TestProv, []},
...> source_resolver: {TestRes, []}
...> )
iex> options.provider
TestProv
iex> options.on_error
:auto