How to use the @sitecore-jss/sitecore-jss.mediaApi.getSrcSet function in @sitecore-jss/sitecore-jss

To help you get started, we’ve selected a few @sitecore-jss/sitecore-jss examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Sitecore / jss / packages / sitecore-jss-angular / src / components / image.directive.ts View on Github external
...fieldAttrs,
      ...parsedAttrs,
    };
    // tslint:disable-next-line:prefer-const
    let { src, srcSet, ...otherAttrs } = combinedAttrs;
    if (!src) {
      return null;
    }
    const newAttrs = {
      ...otherAttrs,
    };
    // update image URL for jss handler and image rendering params
    src = mediaApi.updateImageUrl(src, imageParams);
    if (srcSet) {
      // replace with HTML-formatted srcset, including updated image URLs
      newAttrs.srcSet = mediaApi.getSrcSet(src, srcSet, imageParams);
    } else {
      newAttrs.src = src;
    }
    return newAttrs;
  }
github Sitecore / jss / packages / sitecore-jss-react / src / components / Image.tsx View on Github external
},
  imageParams: any
) => {
  if (!src) {
    return null;
  }

  const newAttrs: any = {
    ...otherAttrs,
  };

  // update image URL for jss handler and image rendering params
  const resolvedSrc = mediaApi.updateImageUrl(src, imageParams);
  if (srcSet) {
    // replace with HTML-formatted srcset, including updated image URLs
    newAttrs.srcSet = mediaApi.getSrcSet(resolvedSrc, srcSet, imageParams);
  } else {
    newAttrs.src = resolvedSrc;
  }
  return newAttrs;
};

@sitecore-jss/sitecore-jss

This module is provided as a part of Sitecore JavaScript Rendering SDK. It contains the core JSS APIs (layout service) and utilities.

Apache-2.0
Latest version published 29 days ago

Package Health Score

84 / 100
Full package analysis

Similar packages