Broadleaf Microservices
  • v1.0.0-latest-prod

Quote React Utils

Utilities provided by @broadleaf/commerce-quote-react.

hasImageParams

Returns whether the URL contains image resize parameters such as ?thumbnail=true.

Parameters

Parameter Type Required? Description

url

URL object

The image URL to check.

imageSizes

Record<string, string>

Mapping of the defined image size parameters

Response

Boolean.

Example

import { hasImageParams } from '@broadleaf/commerce-quote-react';

const url = 'https://www.mycompany.com/green-ghost-primary.png?thumbnail=true'
const hasParams = hasImageParams(url);

console.log(hasParams);

resizeImageWithParam

Adds the given image resize parameter to the image’s content URL.

Parameters

Parameter Type Required? Description

url

string

The image URL to check.

imageSize

string

The size param to add.

gatewayHost

string

The hostname of the Commerce Gateway. Used to determine if the url is absolute or not..

imageSizes

Record<string, string>

Mapping of the defined image size parameters

Response

Boolean.

Example

import { resizeImageWithParam } from '@broadleaf/commerce-quote-react';

const url = 'https://www.mycompany.com/green-ghost-primary.png'
const urlWithParams = resizeImageWithParam(url, 'thumbnail', 'https://localhost:8456');

console.log(urlWithParams);