Overview
Catalyst takes full advantage of the BigCommerce CDN to provide globally-distributed asset hosting and on-the-fly image resizing. This functionality is included with all BigCommerce plans and is agnostic to the hosting provider you use to host your Catalyst storefront.
<BcImage />
and bcCdnImageLoader
For loading images from the BigCommerce platform, Catalyst provides <BcImage />
(opens in a new tab) as a wrapper for Next's <Image />
component to allow you to use the BigCommerce CDN directly to reduce load on the Next.js application and hosting costs.
This component expects to receive the urlTemplate
field from GraphQL Storefront API which contains a {:size}
placeholder which the custom bcCdnImageLoader
image loader (opens in a new tab) will replace with the desired image dimensions. Width is required and height is optional. You may also optionally supply a lossy
parameter to indicate if you would like images to be compressed lossily; the default is true
. If you supply false
, lossless compression will be used.
Using store assets uploaded via WebDAV
Two helper functions are provided in lib/store-assets (opens in a new tab) to help build URLs for assets living in your store's object storage.
contentAssetUrl()
can be used to generate a URL to an arbitrary file asset in the /content/
folder in WebDAV on your store.
Usage:
For image assets uploaded to /content
, you may use contentImageUrl()
to build a resizeable image URL that can be used with <BcImage>
.
Usage:
You may optionally request a specific size for the image, using a size parameter of the form 123w
, 123x123
, or original
.
Usage:
Using Images uploaded to the Image Manager
Use the imageManagerImageUrl()
function to build a CDN URL for an image asset that has been uploaded to the Image Manager. This returns a resizeable URL template that can be used with <BcImage>
.
Usage:
You may optionally request a specific size for the image, using a size parameter of the form 123w
, 123x123
, or original
.
Usage: