Skip to content

Instantly share code, notes, and snippets.

@iamskok
Last active September 28, 2019 11:04
Show Gist options
  • Save iamskok/9aceca8ae19974c4422f9b685847042b to your computer and use it in GitHub Desktop.
Save iamskok/9aceca8ae19974c4422f9b685847042b to your computer and use it in GitHub Desktop.
/** @jsx jsx */
import { jsx } from 'theme-ui'
import { useEffect, useState } from 'react'
import Image from 'gatsby-image'
import { getFluidImageObject } from 'gatsby-transformer-cloudinary'
export default () => {
const [fluid, setFluid] = useState(false)
useEffect(() => {
getFluidImageObject({
public_id: 'gatsby-cloudinary/simpson',
cloudName: 'iamskok',
originalHeight:  264,
originalWidth: 382,
transformations: ['t_gif-to-mp4-transform'],
})
.then(result => setFluid(result))
}, [])
return (
fluid ?
<Image
fluid={ fluid }
sx={{
maxWidth: 382,
maxHeight: 264,
}}
alt="What should be simple is actually pretty painful"
/> :
<div
sx={{
height: '100vh',
width: '100vw',
maxWidth: 382,
maxHeight: 264,
}}
/>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment