Alokai

transformImageUrl

Transforms image URL to the format used by the frontend.

SAPCC returns relative paths to images, so this function can be used to prepend the media host. If no media host is provided, it formats the URL according to SAPCC's internal structure.

Signature

transformImageUrl: (
	url: string,
	sapccMediaHost?: string
) => string

Parameters

NameRequiredTypeDescription
urlRequiredstringThe relative image URL from SAPCC
sapccMediaHostOptionalstringOptional media host URL to prepend to the image path

Returns

The transformed image URL

Examples

// With media host
transformImageUrl('/images/product.jpg', 'https://media-host.com')
// Returns: 'https://media-host.com/images/product.jpg'

// Without media host
transformImageUrl('/images/product.jpg')
// Returns: 'sap/images/product.jpg/context/...'

On this page