Skip to content

Instantly share code, notes, and snippets.

@matiasfha
Last active May 3, 2022 22:19
Show Gist options
  • Save matiasfha/27fc927bfcc63416e2602aedbf73f423 to your computer and use it in GitHub Desktop.
Save matiasfha/27fc927bfcc63416e2602aedbf73f423 to your computer and use it in GitHub Desktop.
createSharingImage utility function using cloudinary transformations
const createSharingImage = ({ cloudName, text }) => {
const imageTransformations = [
'w_1200',
'h_627',
'c_fill',
'q_auto',
'f_auto'
].join(',')
const textTransformations = [
'w_600',
'x_480',
'y_254',
'g_south_west',
'co_white',
`l_text:roboto_64:${encodeURIComponent(text)}`
].join(',')
const baseUrl = `https://res.cloudinary.com/${cloudName}/image/upload/`
return `${baseUrl}${imageTransformations}/${textTransformations}/example_social_card.jpg`
}
export default createSharingImage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment