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
) => stringParameters
| Name | Required | Type | Description |
|---|---|---|---|
url | Required | string | The relative image URL from SAPCC |
sapccMediaHost | Optional | string | Optional 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/...'