Imaginary v0.0.2 Imaginary.Asset View Source

Url module helps manipulating creating urls to cloudinary assets, and can optionally transform the assets as well.

Absolute minimum to create the url is calling Imaginary.Asset.to_url() with AssetData containing cloud_name and id. Check CldConfig documentation for a list of settings that can be set using env variables.

Basic

Use Imaginary.Asset function base() to create the necessary structure, and then id() to add asset id

iex> alias Imaginary.Asset
iex> Asset.base(%CldConfig{ account: %CldAccount{ cloud_name: "demo" }}) 
...> |> Asset.id("sample.jpg") 
...> |> Asset.to_url()
"//res.cloudinary.com/demo/image/upload/sample.jpg"

You can provide necesary struct directly if you really want

iex> %AssetData{id: "sample.jpg", options: %CldConfig{ account: %CldAccount{ cloud_name: "demo" }}}
...> |> Imaginary.Asset.to_url()
"//res.cloudinary.com/demo/image/upload/sample.jpg"

Advanced Examples

iex> alias Imaginary.Asset
iex> Asset.base(%CldConfig{ account: %CldAccount{ cloud_name: "demo-cloud" }}) 
...> |> Asset.width(300) 
...> |> Asset.height(600) 
...> |> Asset.id("sample-image.jpg") 
...> |> Asset.to_url()
"//res.cloudinary.com/demo-cloud/image/upload/w_300/h_600/sample-image.jpg"

Link to this section Summary

Functions

Accepts options, creates necessary data structure. Some options cen be set using env variables.

Add asset id.

Converts asset id and all the transformation to the resulting url

Link to this section Types

Link to this section Functions

Link to this function

base(options \\ %CldConfig{})

View Source

Accepts options, creates necessary data structure. Some options cen be set using env variables.

Link to this function

height(image_data, value)

View Source
height(AssetData.t(), size()) :: AssetData.t()

Set width of the image. Official API Reference

Add asset id.

Converts asset id and all the transformation to the resulting url

Link to this function

width(image_data, value)

View Source
width(AssetData.t(), size()) :: AssetData.t()

Set width of the image. Official API Reference