datocms / gatsby-source-datocms

Official GatsbyJS source plugin to pull content from DatoCMS
MIT License
140 stars 51 forks source link

Get base64 code for image #190

Closed maximeealet closed 1 year ago

maximeealet commented 2 years ago

Hi there,

I need for a project to get the base64 code of an image I upload on DatoCMS. In the Graphql schema base64 is only for blurred image placeholder.

I tried using a resolver to access to the image url and convert it in javascript with no luck as the url field doesn't seem to be accessible by the source arg in my resolve function.

Would you have any lead I could follow to perform this at build time instead of retrieving the url as usual and convert directly inside my page ?

Thanks in advance !

matjack1 commented 1 year ago

Very sorry @maximeealet for forgetting this issue, but maybe it can still be useful to someone else.

Maybe this has changed since your question, but if I've understood correctly, you can get this information from an asset by querying:

resolutions {
    base64
}