Skip to content

Instantly share code, notes, and snippets.

@jarrodmedrano
Created January 26, 2025 14:51
Show Gist options
  • Save jarrodmedrano/b4c1052bd9b3417d8a1f932cffef5417 to your computer and use it in GitHub Desktop.
Save jarrodmedrano/b4c1052bd9b3417d8a1f932cffef5417 to your computer and use it in GitHub Desktop.
Cloudinary resize
const cld = new Cloudinary({
cloud: {
cloudName: "slashclick",
},
});
const myImage = cld.image(popout);
const srcSetOptions = [
{ width: 200, transformation: scale().width(200) },
{ width: 400, transformation: scale().width(400) },
{ width: 600, transformation: scale().width(600) },
{ width: 800, transformation: scale().width(800) },
];
const srcSet = srcSetOptions.map((opt) => ({
src: cld.image(popout).resize(opt.transformation).quality("auto").toURL(),
width: opt.width,
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment