Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array of images #37

Closed
ar7hur opened this issue Jan 12, 2020 · 10 comments
Closed

Array of images #37

ar7hur opened this issue Jan 12, 2020 · 10 comments
Labels
awaiting release This has been fixed on develop but is awaiting a release bug Something isn't working

Comments

@ar7hur
Copy link

ar7hur commented Jan 12, 2020

I'm working with an array of image. With the following config, the plugin adds its localImage field at the root instead of for each element in the pics array.

    {
      resolve: `gatsby-plugin-remote-images`,
      options: {
        nodeType: 'mongodbHeroku_d589dff8Gat',
        imagePath: 'pics[].src',
        prepareUrl: url => `https://mariejordane.com/catalog/${url}`,
      },
    }

My type looks like:

{
  "data": {
    "mongodbHerokuD589Dff8Gat": {
      "name": "Robe A",
      "pics": [
        {
          "src": "H18/IMG_1613.jpg"
        },
        {
          "src": "H18/IMG_1624.jpg"
        }
      ]
    }
  }
}
@wKovacs64
Copy link
Contributor

I've never really understood the array thing, so I may be off base here but maybe try setting nodeType to whatever type defines each pic and then imagePath: 'src'?

{
  "data": {
    "mongodbHerokuD589Dff8Gat": {
      "name": "Robe A",
      "pics": [
        { # <--------------------------- nodeType: whatever type this thing is
          "src": "H18/IMG_1613.jpg"
        },
        {
          "src": "H18/IMG_1624.jpg"
        }
      ]
    }
  }
}

@ar7hur
Copy link
Author

ar7hur commented Jan 13, 2020

@wKovacs64 thanks for your suggestion!
Yeah I had the same idea, I tried with nodeType mongodbHerokuD589Dff8GatPics and imagePath src, it doesn't work.

@sometea
Copy link

sometea commented Jan 13, 2020

I also noticed this issue when upgrading gatsby-plugin-remote-images from version 1 to version 2. In my case, it worked fine in version 1, but on version 2 I'm seeing what you described. @ar7hur , I suspect that your example works fine when downgrading to the plugin version 1.0.7. Could you confirm that?

@ar7hur
Copy link
Author

ar7hur commented Jan 13, 2020

@sometea it works perfectly with version 1.0.7 you are right!

@graysonhicks graysonhicks added the bug Something isn't working label Jan 13, 2020
@wKovacs64
Copy link
Contributor

wKovacs64 commented Jan 13, 2020

@ar7hur Is this a public project, by chance?

tried with nodeType mongodbHerokuD589Dff8GatPics and imagePath src, it doesn't work.

Did this error or just put localImage somewhere unexpected?

@ar7hur
Copy link
Author

ar7hur commented Jan 14, 2020

@wKovacs64 unfortunately not (yet), I'm just starting to work on it!

@wKovacs64
Copy link
Contributor

Sorry, I haven't had time to look into this further.

@graysonhicks The changes in the original effort to temporarily future-proof the plugin (without fully converting to the new Gatsby schema customization approach) seem to have done more harm than good. What do you think about rolling them back and reverting to the old code? It will break at some point in the future, but at least every advertised feature works. We can continue fleshing out a full conversion (like #32 or a different angle) in the meantime, rather than trying to maintain this one-foot-in situation. Thoughts?

@graysonhicks
Copy link
Owner

Hm, yea I am okay with that. With #32, will we have this array of images bug still? It looks like main thing holding #32 back is the build times issue. @wKovacs64

@wKovacs64
Copy link
Contributor

Hm, yea I am okay with that.

OK, I'll try to throw a quick PR together later that rolls it back. You'll want to publish 2.1.1 or something to fix 2.x users.

With #32, will we have this array of images bug still? It looks like main thing holding #32 back is the build times issue.

The main issue with #32 currently is the build times, but so far, it seems to be a Gatsby design issue rather than anything specific to this plugin. So we either expect users to deal with it like @kilburn chose to do, or find an entirely different approach (which has yet to reveal itself).

The array thing will morph. Instead of being able to augment an arbitrary nodeType ancestor, the newly created File node will exist at the same level as the image URL. You don't lose functionality, it just has to live somewhere else. I explained it as best I could in the migration guide included in the PR. That's not to say retaining the current (1.x / unbroken) approach is impossible, it's just not how #32 does it. 🤷‍♂

@graysonhicks graysonhicks added the awaiting release This has been fixed on develop but is awaiting a release label Jul 7, 2020
@graysonhicks
Copy link
Owner

Released with v2.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting release This has been fixed on develop but is awaiting a release bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants