Astral.Image.Remote (Astral v0.1.4)

Copy Markdown View Source

Remote image allowlisting and source caching.

Remote URLs are never optimized unless they match an explicit allow_remote pattern. Redirects are followed manually and each destination must also match the allowlist, mirroring Astro's security model.

Summary

Functions

Return true when a remote image URL matches configured allowlist patterns.

Return true when a source string is an HTTP(S) URL.

Resolve a remote image URL to a cached local source path.

Types

cached()

@type cached() :: %Astral.Image.Remote{
  etag: String.t() | nil,
  expires_at: integer(),
  final_url: String.t(),
  last_modified: String.t() | nil,
  path: String.t(),
  url: String.t()
}

Functions

allowed?(url, image_config)

@spec allowed?(String.t(), Astral.Image.Config.t()) :: boolean()

Return true when a remote image URL matches configured allowlist patterns.

remote?(source)

@spec remote?(term()) :: boolean()

Return true when a source string is an HTTP(S) URL.

resolve(url, image_config)

@spec resolve(String.t(), Astral.Image.Config.t()) ::
  {:ok, cached()} | {:error, term()}

Resolve a remote image URL to a cached local source path.