Image preview src is undefined?

Hi there! Not sure what I’m doing wrong here, but having a little trouble getting my image preview to show up. Here’s my previewSrc set up:

 previewSrc: (formValues, fieldProps) => {
          const pathName = fieldProps.input.name.replace("rawJson", "jsonNode")
          const imageNode = get(formValues, pathName)
          if (!imageNode || !imageNode.childImageSharp) return ""
          return imageNode.childImageSharp.fluid.src
        },

I think it’s cause get(formValues, pathName) seems to be logging out as undefined

Is formValues supposed to have a jsonNode property in the returned object? If so, looks like it’s missing.

Thanks so much for the help!

gatsby-config.js

const path = require("path")

module.exports = {
  plugins: [
    {
      resolve: "gatsby-source-filesystem",
      options: {
        name: "data",
        path: `${__dirname}/content/data`,
      },
    },
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        name: "assets",
        path: `${__dirname}/content/assets`,
      },
    },
    "gatsby-transformer-json",
    {
      resolve: "gatsby-plugin-sharp",
      options: {
        defaultQuality: 75,
      },
    },
    `gatsby-transformer-sharp`,
    {
      resolve: "gatsby-transformer-remark",
      options: {
        plugins: [
          {
            resolve: "gatsby-remark-images",
            options: {
              maxWidth: 1000,
              // linkImagesToOriginal: true,
            },
          },
        ],
      },
    },
    {
      resolve: "gatsby-plugin-tinacms",
      options: {
        plugins: [
          "gatsby-tinacms-json",
          "gatsby-tinacms-remark",
          {
            resolve: 'gatsby-tinacms-git',
            options: {
              pathToRepo: process.cwd(),
              pathToContent: "",
              defaultCommitMessage: 'Edited with TinaCMS',
              defaultCommitName: 'TinaCMS',
              defaultCommitEmail: 'git@tinacms.org',
              pushOnCommit: false,
            },
          },
        ],
        sidebar: {
          hidden: process.env.NODE_ENV === "production",
          position: "displace",
        },
      },
    },
  ],
}

Dependencies

├─┬ gatsby-plugin-tinacms@0.2.1
│ └─┬ tinacms@0.21.1
│   ├── @tinacms/alerts@0.1.4
│   ├── @tinacms/core@0.9.0
│   ├─┬ @tinacms/fields@0.11.2
│   ├─┬ @tinacms/form-builder@0.3.5
│   ├─┬ @tinacms/forms@0.6.0
│   ├── @tinacms/icons@0.13.0
│   ├── @tinacms/media@0.1.0
│   ├── @tinacms/react-alerts@0.1.8
│   ├─┬ @tinacms/react-core@0.3.0
│   ├─┬ @tinacms/react-forms@0.1.8
│   ├── @tinacms/react-modals@0.1.8
│   ├── @tinacms/react-screens@0.1.7
│   ├─┬ @tinacms/react-sidebar@0.1.8
│   ├─┬ @tinacms/react-toolbar@0.1.6
│   ├─┬ @tinacms/styles@0.5.1
├─┬ gatsby-tinacms-git@0.5.2
│ ├─┬ @tinacms/api-git@0.7.0
│ └── @tinacms/git-client@0.6.7
├─┬ gatsby-tinacms-json@0.8.26
├─┬ gatsby-tinacms-remark@0.8.1
│ ├─┬ react-tinacms-editor@0.8.0
│ ├─┬ react-tinacms-inline@0.7.0

Hey @Alex I think this is actually a bug!

Thanks for bringing it up. We’re looking into fixing it now. We’ll try to hotfix it today!

The PR

Just published the fix. Please let us know if it’s working for you now :slight_smile:

Amazing! Works perfect now! TYSM!