noxify / gridsome-plugin-remote-image

simple plugin to download remote images in gridsome
MIT License
14 stars 16 forks source link

Unable to download images from contentful source #23

Closed noxify closed 3 years ago

noxify commented 3 years ago

While trying to download an image from a contentful source, the download fails and the target field has the same value as the source field.

Rootcause: The image url inside the contentful aaset collection is //. The image download plugin requires https:// or http://.

Solution: Check the download url and add the missing protocol if needed.

travis-r6s commented 3 years ago

As a fix in the meantime, you can use onCreateNode to add that missing protocol: gridsome.server.js

module.exports = api => {
    api.onCreateNode(node => {
        if (node.internal.typeName === 'ContentfulAsset') {
            node.file.url = `https:${node.file.url}`
        }
    })
}
noxify commented 3 years ago

@DouglasKGlover - this should fix your problem :)

DouglasKGlover commented 3 years ago

@noxify Thanks a lot for handling this!

noxify commented 3 years ago

If something isn't working, feel free to create an issue here :)