AEM Assets integration
The AEM Assets integration allows your storefront to display product images that are managed in AEM Assets instead of traditional Commerce-hosted images. This integration provides enhanced image management capabilities, including advanced optimization, cropping, and delivery through Adobe’s Content Delivery Network (CDN).
Boilerplate update required
Only one update is required: set "commerce-assets-enabled": true
in your Storefront configuration.
{ "public": { "default": { "commerce-assets-enabled": true } }}
The Commerce drop-ins automatically detect the commerce-assets-enabled
configuration and adjust image handling accordingly. See the demo configratuion.
Expected behaviors
The following table describes what happens in different configuration scenarios. The Image source refers to where you store your images: either “Commerce” for traditional Commerce-hosted images or “AEM Assets” for images managed in AEM Assets. For background, see the AEM Assets Integration documentation. The commerce-assets-enabled setting
column indicates whether this configuration is set to true
or false
.
How it works in the boilerplate
The Commerce drop-ins automatically detect the commerce-assets-enabled
configuration and adjust image handling accordingly. Here’s how the boilerplate integrates this configuration:
Import the AEM Assets utility
The Commerce blocks in the boilerplate import the tryRenderAemAssetsImage
helper from the drop-ins tools package.
import { tryRenderAemAssetsImage } from '@dropins/tools/lib/aem/assets.js';
Render images via drop-in slots
The Commerce blocks use the tryRenderAemAssetsImage
function inside its drop-in image slots, as shown below.
import { tryRenderAemAssetsImage } from '@dropins/tools/lib/aem/assets.js';
export default async function decorate(block) {
await dropinRenderer.render(DropinComponent, {
slots: { DropinImageSlot: (ctx) => { const { data, defaultImageProps } = ctx;
tryRenderAemAssetsImage(ctx, { imageProps: defaultImageProps, params: { width: defaultImageProps.width, height: defaultImageProps.height, }, }); }, }, })(block);}
Real-world examples from the boilerplate
Based on the Commerce blocks in the boilerplate, AEM Assets integration uses the tryRenderAemAssetsImage
function from @dropins/tools/lib/aem/assets.js
as follows.
Product List SearchResults container
import { tryRenderAemAssetsImage } from '@dropins/tools/lib/aem/assets.js';
provider.render(SearchResults, {
slots: { ProductImage: (ctx) => { const { product, defaultImageProps } = ctx; const anchorWrapper = document.createElement('a'); anchorWrapper.href = rootLink(`/products/${product.urlKey}/${product.sku}`);
tryRenderAemAssetsImage(ctx, { alias: product.sku, imageProps: defaultImageProps, wrapper: anchorWrapper, params: { width: defaultImageProps.width, height: defaultImageProps.height, }, }); }, },});
Checkout OrderProductList container
import { tryRenderAemAssetsImage } from '@dropins/tools/lib/aem/assets.js';
OrderProvider.render(OrderProductList, {
slots: { CartSummaryItemImage: (ctx) => { const { data, defaultImageProps } = ctx;
tryRenderAemAssetsImage(ctx, { alias: data.product.sku, imageProps: defaultImageProps, params: { width: defaultImageProps.width, height: defaultImageProps.height, }, }); }, ... },})($orderProductList);
Using drop-ins outside the boilerplate (optional)
If you use the boilerplate, AEM Assets works out of the box. Without the boilerplate, you need to implement the minimal config and slot usage below. See the Commerce drop-ins overview for how slots and initializers work.
To enable AEM Assets with standalone drop-ins, you’ll need to implement the configuration system that drop-ins expect. See Storefront configuration for full configuration details.
Minimal configuration
Set commerce-assets-enabled: true
in a public.default
config (JSON or config service). Align endpoints/headers to your environment as needed.
Minimal integration steps
- Install
@dropins/tools
. - Add the
assets.js
file from the boilerplate to your project. - Import
tryRenderAemAssetsImage
into your drop-in components. - In each image slot, call
tryRenderAemAssetsImage(ctx, { alias: <sku>, imageProps, params: { width, height } })
. Fallback to Commerce-hosted images is automatic from functions inassets.js
—no extra code is required. - Use the product SKU (or your configured alias) for
alias
so the correct asset is matched in AEM. - When linking images, pass a
wrapper
element (for example, an anchor) in the options. - Set the
width
/height
params to the slot’s intended render size (e.g., fromdefaultImageProps
). - For more details, see Commerce drop-ins overview.
Minimal implementation results: Uses AEM Assets when available; falls back to Commerce; applies correct CDN params automatically.
Troubleshooting
Images not displaying
If product images are not displaying correctly:
- Check your configuration: Ensure
commerce-assets-enabled
is set totrue
if you’re using AEM Assets. - Verify image URLs: AEM Assets images typically include specific URL patterns that indicate they’re served from AEM.
- Check browser console: Look for 400 errors that might indicate incompatible optimization parameters.
- Test with mixed sources: Try with both AEM Assets and Commerce-hosted images to isolate the issue.
- Confirm slot integration: If not using the boilerplate, ensure each drop-in image slot calls
tryRenderAemAssetsImage
with a validalias
(SKU). - Validate size params: Ensure
params.width
/params.height
match the slot’s intended render size (for example, fromdefaultImageProps
).
Configuration not taking effect
- Clear cache: Ensure your configuration changes are not cached.
- Check config location: Verify your storefront configuration is properly formatted.
- Validate JSON: Use a JSON validator to ensure your configuration file is valid.