Skip to content

Instantly share code, notes, and snippets.

@sadez
Last active June 4, 2020 14:59
Show Gist options
  • Save sadez/79707be1e2172f0f55c5dbbdb4926570 to your computer and use it in GitHub Desktop.
Save sadez/79707be1e2172f0f55c5dbbdb4926570 to your computer and use it in GitHub Desktop.
get url CDN
const getURLFromCDN = (imageURL, height, quality) => {
// url formatting depend on CDN
return `${CDNimagePath}/${imageURL}?height=${Math.round(height)}&format=jpg&q=${quality}`;
};
// render
<FastImage
source={{ uri: getURLFromCDN("https://url/image.png", 200, 80) }} // https://cdnurl/https://url/image.png?height=200&q=80&format=jpg
style={imgStyle}
/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment