Closed megant closed 4 years ago
@megant I can see the issue here. I believe adding a "field" option to filter by would solve this. That way you could specify something like:
{
resolve: 'gatsby-remark-relative-images',
options: {
fmFields: ['image'],
},
},
}
@megant I can see the issue here. I believe adding a "field" option to filter by would solve this. That way you could specify something like:
{ resolve: 'gatsby-remark-relative-images', options: { fmFields: ['image'], }, }, }
I tried something similar (I used exceptions instead of fmFields and in contained fields which don't have to be converted), but my problem was fmImagesToRelative runs before plugin options initialization.
Yea, I just found that out too. Sorry, I haven't used this much since I wrote it :wink:. I will take a look at maybe passing a "filter" method option to the function which you could use to determine which fields were converted.
On Fri, May 10, 2019 at 2:24 PM megant notifications@github.com wrote:
@megant https://github.com/megant I can see the issue here. I believe adding a "field" option to filter by would solve this. That way you could specify something like:
{ resolve: 'gatsby-remark-relative-images', options: { fmFields: ['image'], }, }, }
I tried something similar (I used exceptions instead of fmFields and in contained fields which don't have to be converted), but my problem was fmImagesToRelative runs before plugin options initialization.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/danielmahon/gatsby-remark-relative-images/issues/18#issuecomment-491386337, or mute the thread https://github.com/notifications/unsubscribe-auth/AAIJUWJJ6I3VLGKVEGGNP3DPUW4V7ANCNFSM4HLX5DTQ .
@danielmahon Has there been any movement on this?
@danielmahon I'm having a similar issue. Having a filter would solve it.
I could give it a go if it's still needed?
add options in fb63dd3
OK, let me draw up the problem. When I call fmImagesToRelative(node) in the onCreateNode hook of gatsy-node.js, the node argument of the function contains all the node data. Let's say I create a page dynamically according to the markdow below:
`---
title: Title
image: /content/images/image_name.jpg
slug: /my/multilingual/slug`
When this markdown data passed to fmImagesToRelative function, in the inside at row 233. the image validation is like:
if (!file.dir) return;
It means everything that looks like image path is surely an image path. This approach is wrong, because in this way every path will be converted to relative path instead of only paths related to the plugin's settings, eg:
plugins: [... { resolve: 'gatsby-remark-relative-images', options: { name: 'only-this-named-source', }, }, ...]
You should handle this somehow, otherwise we've to face lot of unwanted issues at build process.