Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ImageUrlBuilder

Utility which helps construct URLs to image resources hosted using the Amplience Dynamic Media platform.

Commonly used transformations can chained together by calling the appropriate function on the builder. Advanced transformations can be used by configuring a transformation template within the Amplience back-office and applying the template to the builder.

Hierarchy

  • ImageUrlBuilder

Index

Constructors

constructor

Properties

Private _format

_format: ImageFormat

Private _host

_host: string

Private _protocol

_protocol: string = "https"

Private Readonly _query

_query: string[] = []

Private _seoFileName

_seoFileName: string

Private Readonly media

media: Media

Methods

build

  • build(): string

format

  • Format converts the image to the file format specified. The format will be appended to the URL as a file extension.

    https://images.site.com/i/account/image.webp

    Parameters

    • value: ImageFormat

      Images format to use when encoding the output.

    Returns this

height

  • height(value: number): this
  • Height resizes an image to the pixel size provided. If you only provide one axis, the other will be calculated to maintain aspect ratio. Use the scale mode parameter to apply different resize effects like stretch or crop.

    https://images.site.com/i/account/image?h={{value}}

    Parameters

    • value: number

      The new height in pixels.

    Returns this

host

  • host(value: string): this
  • Host configures the hostname to use when building the image URL. By default, the SDK will use the most appropriate hostname based on the SDK configuration.

    https://{{host}}/i/account/image

    Parameters

    • value: string

      Hostname to use instead of the default value.

    Returns this

parameter

  • parameter(name: string, value: string): this
  • Parameter appends the specified parameter to the query string. This can be used to pass variables into templates.

    https://images.site.com/i/account/image?{{name}}={{value}}

    Parameters

    • name: string
    • value: string

    Returns this

protocol

  • protocol(value: string): this
  • Protocol configures what protocol style to use when building the image URL.

    {{protocol}}[:]//images.site.com/i/account/image

    Parameters

    • value: string

      URL protocol, valid values are: http, https and // for protocol relative URLs

    Returns this

quality

  • quality(value: number): this
  • Quality sets the compression level for the image output

    https://images.site.com/i/account/image?qlt={{value}}

    Parameters

    • value: number

      The quality percentage (0-100)

    Returns this

seoFileName

  • seoFileName(value: string): this
  • SEO filename allows a custom filename to be used to improve SEO.

    https://images.site.com/i/account/image/{{seoFileName}}

    Parameters

    • value: string

    Returns this

sharpen

  • sharpen(radius?: number, sigma?: number, amount?: number, threshold?: number): this
  • Sharpen applies an unsharp mask to the image to refine edges or make an image look more crisp.

    https://images.site.com/i/account/image?unsharp={{radius}},{{sigma}},{{amount}},{{threshold}}

    Parameters

    • Default value radius: number = 0

      The radius of the Gaussian, in pixels, not counting the center pixel.

    • Default value sigma: number = 1

      The standard deviation of the Gaussian, in pixels.

    • Default value amount: number = 1

      The percentage of the difference between the original and the blur image that is added back into the original.

    • Default value threshold: number = 0.05

      The threshold, as a fraction of MaxRGB, needed to apply the difference amount.

    Returns this

template

  • template(name: string): this
  • Template applies a transformation template to the image, which will apply all of the transformation parameters contained in the template to the image.

    https://images.site.com/i/account/image?${{name}}$

    Parameters

    • name: string

      The name of the transformation template previously configured in the Amplience back-office.

    Returns this

width

  • width(value: number): this
  • Width resizes an image to the pixel size provided. If you only provide one axis, the other will be calculated to maintain aspect ratio. Use the scale mode parameter to apply different resize effects like stretch or crop.

    https://images.site.com/i/account/image?w={{value}}

    Parameters

    • value: number

      The new width in pixels.

    Returns this

Generated using TypeDoc