abstract class BaseMediaAsset extends BaseAsset implements CommonTransformationInterface

Class BaseMediaAsset

Properties

CloudConfig $cloud from BaseAsset
UrlConfig $urlConfig from BaseAsset
AssetDescriptor $asset from BaseAsset
AuthToken $authToken from BaseAsset
ImageTransformation|VideoTransformation|Transformation $transformation

Methods

cdnSubdomain(bool $cdnSubdomain = true)

Whether to automatically build URLs with multiple CDN sub-domains.

secureCdnSubdomain(bool $secureCdnSubdomain = true)

Whether to use secure CDN sub-domain.

cname(string $cname)

The custom domain name to use for building HTTP URLs.

secure(bool $secure = true)

Force HTTPS URLs for resources even if they are embedded in non-secure HTTP pages.

secureCname(string $secureCname)

The domain name of the CDN distribution to use for building HTTPS URLs.

privateCdn(bool $privateCdn = true)

Set this parameter to true if you are an Advanced plan user with a private CDN distribution.

signUrl(bool $signUrl = true)

Set to true to create a signed Cloudinary URL.

longUrlSignature(bool $longUrlSignature = true)

Setting both this and signUrl to true will sign the URL using the first 32 characters of a SHA-256 hash.

shorten(bool $shorten = true)

Set to true to use shorten asset type.

useRootPath(bool $useRootPath = true)

Set to true to omit type and resource_type in the URL.

forceVersion(bool $forceVersion = true)

Set to false to omit default version string for assets in folders in the delivery URL.

analytics(bool $analytics = true)

Set to false to omit analytics.

__construct($source, mixed $configuration = null)

BaseMediaAsset constructor.

fromString(string $string)

Creates a new asset from the provided string (URL).

fromJson(string|array $json)

Creates a new asset from the provided JSON.

fromParams(string $source, array $params = [])

Creates a new media asset from the provided public and array of parameters.

importString(string $string)

Imports data from the provided string (URL).

importJson(string|array $json)

Imports data from the provided JSON.

configuration(array|Configuration $configuration)

Sets the asset configuration.

importConfiguration(array|Configuration $configuration)

Imports (merges) the asset configuration.

getPublicId(bool $omitExtension = false)

Returns the public ID of the asset.

setPublicId(string $publicId)

Sets the public ID of the asset.

toUrl(CommonTransformation|string $withTransformation = null, bool $append = true)

Serializes to the URL string.

__toString()

Serializes to string.

jsonSerialize($includeEmptyKeys = false, $includeEmptySections = false)

No description

setTransformation(CommonTransformation $transformation)

Sets the transformation.

getTransformation()

Gets the asset transformation.

addTransformation(CommonTransformation|array|string $transformation)

Adds (appends) a transformation.

addAction(BaseAction|BaseQualifier|mixed $action)

Adds (chains) a transformation action.

setFormat(string $format, bool $useFetchFormat = false)

Sets the asset format.

Details

$this cdnSubdomain(bool $cdnSubdomain = true)

Whether to automatically build URLs with multiple CDN sub-domains.

Parameters

Name Type Description
$cdnSubdomain bool

Return Value

$this

See also

https://cloudinary.com/documentation/advanced_url_delivery_options#multiple_sub_domains

$this secureCdnSubdomain(bool $secureCdnSubdomain = true)

Whether to use secure CDN sub-domain.

Parameters

Name Type Description
$secureCdnSubdomain bool

Return Value

$this

$this cname(string $cname)

The custom domain name to use for building HTTP URLs.

Relevant only for Advanced plan users that have a private CDN distribution and a custom CNAME.

Parameters

Name Type Description
$cname string

Return Value

$this

See also

https://cloudinary.com/documentation/advanced_url_delivery_options#private_cdns_and_cnames

$this secure(bool $secure = true)

Force HTTPS URLs for resources even if they are embedded in non-secure HTTP pages.

Parameters

Name Type Description
$secure bool

Return Value

$this

$this secureCname(string $secureCname)

The domain name of the CDN distribution to use for building HTTPS URLs.

Relevant only for Advanced plan users that have a private CDN distribution.

Parameters

Name Type Description
$secureCname string The CNAME for secure (https) URLs.

Return Value

$this

See also

https://cloudinary.com/documentation/advanced_url_delivery_options#private_cdns_and_cnames

$this privateCdn(bool $privateCdn = true)

Set this parameter to true if you are an Advanced plan user with a private CDN distribution.

Parameters

Name Type Description
$privateCdn bool

Return Value

$this

See also

https://cloudinary.com/documentation/advanced_url_delivery_options#private_cdns_and_cnames

$this signUrl(bool $signUrl = true)

Set to true to create a signed Cloudinary URL.

Parameters

Name Type Description
$signUrl bool

Return Value

$this

$this longUrlSignature(bool $longUrlSignature = true)

Setting both this and signUrl to true will sign the URL using the first 32 characters of a SHA-256 hash.

Parameters

Name Type Description
$longUrlSignature bool

Return Value

$this

See also

https://cloudinary.com/documentation/advanced_url_delivery_options#generating_delivery_url_signatures

$this shorten(bool $shorten = true)

Set to true to use shorten asset type.

Parameters

Name Type Description
$shorten bool

Return Value

$this

$this useRootPath(bool $useRootPath = true)

Set to true to omit type and resource_type in the URL.

Parameters

Name Type Description
$useRootPath bool

Return Value

$this

See also

https://cloudinary.com/documentation/advanced_url_delivery_options#root_path_urls

$this forceVersion(bool $forceVersion = true)

Set to false to omit default version string for assets in folders in the delivery URL.

Parameters

Name Type Description
$forceVersion bool

Return Value

$this

$this analytics(bool $analytics = true)

Set to false to omit analytics.

Parameters

Name Type Description
$analytics bool Whether to include analytics.

Return Value

$this

__construct($source, mixed $configuration = null)

BaseMediaAsset constructor.

Parameters

Name Type Description
$source
$configuration mixed

static mixed fromString(string $string)

Creates a new asset from the provided string (URL).

Parameters

Name Type Description
$string string The asset string (URL).

Return Value

mixed

static mixed fromJson(string|array $json)

Creates a new asset from the provided JSON.

Parameters

Name Type Description
$json string|array The asset json. Can be an array or a JSON string.

Return Value

mixed

static mixed fromParams(string $source, array $params = [])

Creates a new media asset from the provided public and array of parameters.

Parameters

Name Type Description
$source string The public ID of the asset.
$params array The asset parameters.

Return Value

mixed

mixed importString(string $string)

Imports data from the provided string (URL).

Parameters

Name Type Description
$string string The asset string (URL).

Return Value

mixed

mixed importJson(string|array $json)

Imports data from the provided JSON.

Parameters

Name Type Description
$json string|array The asset json. Can be an array or a JSON string.

Return Value

mixed

BaseAsset configuration(array|Configuration $configuration)

Sets the asset configuration.

Parameters

Name Type Description
$configuration array|Configuration The configuration source.

Return Value

BaseAsset

BaseAsset importConfiguration(array|Configuration $configuration)

Imports (merges) the asset configuration.

Parameters

Name Type Description
$configuration array|Configuration The configuration source.

Return Value

BaseAsset

string getPublicId(bool $omitExtension = false)

Returns the public ID of the asset.

Parameters

Name Type Description
$omitExtension bool Indicates whether to exclude the file extension.

Return Value

string

BaseAsset setPublicId(string $publicId)

Sets the public ID of the asset.

Parameters

Name Type Description
$publicId string The public ID.

Return Value

BaseAsset

string toUrl(CommonTransformation|string $withTransformation = null, bool $append = true)

Serializes to the URL string.

Parameters

Name Type Description
$withTransformation CommonTransformation|string Optional transformation that can be appended/used instead.
$append bool Whether to append or use the provided transformation.

Return Value

string

Exceptions

ConfigurationException

string __toString()

Serializes to string.

Return Value

string

jsonSerialize($includeEmptyKeys = false, $includeEmptySections = false)

Parameters

Name Type Description
$includeEmptyKeys
$includeEmptySections

BaseMediaAsset setTransformation(CommonTransformation $transformation)

Sets the transformation.

Parameters

Name Type Description
$transformation CommonTransformation The transformation

Return Value

BaseMediaAsset

abstract ImageTransformation|VideoTransformation|Transformation getTransformation()

Gets the asset transformation.

Return Value

ImageTransformation|VideoTransformation|Transformation

$this addTransformation(CommonTransformation|array|string $transformation)

Adds (appends) a transformation.

Appended transformation is nested.

Parameters

Name Type Description
$transformation CommonTransformation|array|string The transformation to add.

Return Value

$this

BaseMediaAsset addAction(BaseAction|BaseQualifier|mixed $action)

Adds (chains) a transformation action.

Parameters

Name Type Description
$action BaseAction|BaseQualifier|mixed The transformation action to add. If BaseQualifier is provided, it is wrapped with action.

Return Value

BaseMediaAsset

BaseMediaAsset setFormat(string $format, bool $useFetchFormat = false)

Sets the asset format.

For non-fetched assets sets the filename extension. For remotely fetched assets sets the 'f_' transformation parameter.

Parameters

Name Type Description
$format string The format to set.
$useFetchFormat bool Whether to force fetch format behavior.

Return Value

BaseMediaAsset