silverwolf-x's picture
download
raw
756 Bytes
import Image from "next/image";
const DEFAULT_QUALITY = 20;
// https://dotcms.com/docs/latest/image-resizing-and-processing
const getUrlWithResizingParameters = ({
src,
width,
quality = DEFAULT_QUALITY,
}) => {
const urlParams = [];
const lastSeparatorIdx = src.lastIndexOf("/");
const imageIdentifierAndField = src.slice(0, lastSeparatorIdx);
urlParams.push(imageIdentifierAndField);
urlParams.push(width + "w");
urlParams.push(quality + "q");
return urlParams.join("/");
};
const dotCmsLoader = (props) => {
return `${process.env.NEXT_PUBLIC_DOTCMS_HOST}${getUrlWithResizingParameters(
props,
)}`;
};
const DotCmsImage = (params) => {
return <Image {...params} loader={dotCmsLoader} />;
};
export default DotCmsImage;

Xet Storage Details

Size:
756 Bytes
·
Xet hash:
7ce817fcb26300768c5d569fc435cd791b5102f49347eea63c40464ee98ece28

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.