An image content item for Deep Linking responses.
The platform renders the image directly using an HTML img tag.
For images that are part of a larger resource, consider using
Ltix.DeepLinking.ContentItem.Link with an embed.
Examples
iex> {:ok, image} = Ltix.DeepLinking.ContentItem.Image.new(
...> url: "https://example.com/diagram.png",
...> width: 800
...> )
iex> Ltix.DeepLinking.ContentItem.to_map(image)
%{"type" => "image", "url" => "https://example.com/diagram.png", "width" => 800}Options
:title(String.t/0) - Title for the content item.:text(String.t/0) - Plain-text description.:extensions(nil|map/0) - Required. Vendor-specific extension properties. The default value is%{}.:width(integer/0) - Width of the image in pixels.:url(String.t/0) - Required. URL of the image.:height(integer/0) - Height of the image in pixels.:icon(map/0) - Icon or thumbnail for the image.:thumbnail(map/0) - Icon or thumbnail for the image.
Summary
Types
@type t() :: %Ltix.DeepLinking.ContentItem.Image{ extensions: nil | %{optional(binary() | atom()) => any()}, height: nil | integer(), icon: nil | %{ optional(:width) => integer(), :url => binary(), optional(:height) => integer() }, text: nil | binary(), thumbnail: nil | %{ optional(:width) => integer(), :url => binary(), optional(:height) => integer() }, title: nil | binary(), url: binary(), width: nil | integer() }
Functions
@spec new(keyword() | map()) :: {:ok, t()} | {:error, Exception.t()}
Create a new image content item.
Takes the module's options as a keyword list or map, and nested options such as
icon may also be keyword lists. Unknown or invalid options return an
Ltix.Errors.Invalid.InvalidField error.
Examples
iex> {:ok, image} = Ltix.DeepLinking.ContentItem.Image.new(url: "https://example.com/photo.png")
iex> image.url
"https://example.com/photo.png"
iex> {:error, error} = Ltix.DeepLinking.ContentItem.Image.new([])
iex> Exception.message(error)
"Ltix.DeepLinking.ContentItem.Image field :url is required [DL §3.5]"
Same as new/1 but raises on error.
Examples
iex> Ltix.DeepLinking.ContentItem.Image.new!(url: "https://example.com/photo.png").url
"https://example.com/photo.png"