cloudex v1.2.2 Cloudex.Url

A module that helps creating urls to your cloudinary image, which can optionally transform the image as well.

Link to this section Summary

Functions

Given a cloudinary public id string, this will generate an image url of where the image is hosted. You can also pass a map with options to apply transformations to the image, for more information see the documentation

Link to this section Functions

Link to this function

for(public_id, options \\ %{})
for(String.t(), map()) :: String.t()

Given a cloudinary public id string, this will generate an image url of where the image is hosted. You can also pass a map with options to apply transformations to the image, for more information see the documentation.

examples :

An url to the image at its original dimensions and no transformations

iex> Cloudex.Url.for("a_public_id")
"//res.cloudinary.com/my_cloud_name/image/upload/a_public_id"

An url to the image with just a signature

iex> Cloudex.Url.for("a_public_id", %{sign_url: true})
"//res.cloudinary.com/my_cloud_name/image/upload/s--MXxhpIBQ--/a_public_id"

An url to the image adjusted to a specific width and height

iex> Cloudex.Url.for("a_public_id", %{width: 400, height: 300})
"//res.cloudinary.com/my_cloud_name/image/upload/h_300,w_400/a_public_id"

An url to the image using multiple transformation options and a signature

iex> Cloudex.Url.for("a_public_id", %{crop: "fill", fetch_format: 'auto', flags: 'progressive', width: 300, height: 254, quality: "jpegmini", sign_url: true})
"//res.cloudinary.com/my_cloud_name/image/upload/s--jwB_Ds4w--/c_fill,f_auto,fl_progressive,h_254,q_jpegmini,w_300/a_public_id"

An url to the image using a named transformation

iex> Cloudex.Url.for("a_public_id", %{transformation: "my_transformation"})
"//res.cloudinary.com/my_cloud_name/image/upload/t_my_transformation/a_public_id"

An url to a specific version of the image

iex> Cloudex.Url.for("a_public_id", %{version: 1471959066})
"//res.cloudinary.com/my_cloud_name/image/upload/v1471959066/a_public_id"

An url to a specific version of the image adjusted to a specific width and height

iex> Cloudex.Url.for("a_public_id", %{width: 400, height: 300, version: 1471959066})
"//res.cloudinary.com/my_cloud_name/image/upload/h_300,w_400/v1471959066/a_public_id"

An url to the image with the file extension of the requested delivery format for the resource. The resource is delivered in the original uploaded format if the file extension is not included.

iex> Cloudex.Url.for("a_public_id", %{format: "png"})
"//res.cloudinary.com/my_cloud_name/image/upload/a_public_id.png"

An url to the resource type. If resource type not specified, "image" is the default

iex> Cloudex.Url.for("a_public_id", %{resource_type: "video"})
"//res.cloudinary.com/my_cloud_name/video/upload/a_public_id"

An url to the resource type with a named transformation.

iex> Cloudex.Url.for("a_public_id", %{resource_type: "video", transformation: "my_transformation"})
"//res.cloudinary.com/my_cloud_name/video/upload/t_my_transformation/a_public_id"

An url with an overlay

iex> Cloudex.Url.for("a_public_id", [
...>   %{border: "5px_solid_rgb:c22c33", radius: 5, crop: "fill", height: 246, width: 470, quality: 80},
...>   %{overlay: "my_overlay", crop: "scale", gravity: "south_east", width: 128 ,x: 5, y: 15}
...> ])
"//res.cloudinary.com/my_cloud_name/image/upload/bo_5px_solid_rgb:c22c33,c_fill,h_246,q_80,r_5,w_470/c_scale,g_south_east,l_my_overlay,w_128,x_5,y_15/a_public_id"

An url with a face

iex> Cloudex.Url.for("a_public_id", %{width: 400, height: 300, face: true})
"//res.cloudinary.com/my_cloud_name/image/upload/g_face,h_300,w_400/a_public_id"

An url with a video codec setting

iex> Cloudex.Url.for("a_public_id", %{resource_type: "video", video_codec: "h265"})
"//res.cloudinary.com/my_cloud_name/video/upload/vc_h265/a_public_id"

An url with zoom applied to a face

iex> Cloudex.Url.for("a_public_id", %{zoom: 1.3, face: true, crop: "crop", version: 1471959066})
"//res.cloudinary.com/my_cloud_name/image/upload/c_crop,g_face,z_1.3/v1471959066/a_public_id"

An url retaining aspect ratio

iex> Cloudex.Url.for("a_public_id", %{aspect_ratio: 2.5, width: 400, height: 300, version: 1471959066})
"//res.cloudinary.com/my_cloud_name/image/upload/ar_2.5,h_300,w_400/v1471959066/a_public_id"