\n \n `/assets/${filename}`}\n uploadDir={() => '/public/assets'}\n previewSrc={formValues => `${formValues.blocks[index].left.src}`}\n focusRing={false}\n />\n
\n \n )\n}\n```\n\nThe return value should be the entire path to the image from the source data — e.g. `/example-dir/image.jpg`.\n\n### Accessing block index in the template fields\n\nUsing the `index` in the `previewSrc` to target the correct block is very helpful. While `index` is passed to the _Block Component_, it is not directly available in the _Block Template_.\n\nOne way to work around this is to access the second argument, `input`. Manipulate the form input data to get the index of the current field.\n\nSee the example below for a variation on getting the block index:\n\n**components/Images.js**\n\n```jsx\nexport const imagesBlock = {\n Component: Images,\n template: {\n //... Other block template config\n fields: [\n {\n name: 'left.src',\n label: 'Left-Hand Image',\n component: 'image',\n parse: filename => `/${filename}`,\n uploadDir: () => '/',\n previewSrc: (formValues, input) => {\n /**\n * Get index from field input. Assumes the block\n * is only one level deep\n */\n const index = input.field.name.split('.')[1]\n /**\n * Use that index to target the correct\n * block in `formValues`\n */\n const currentBlockImage = formValues.blocks[index].left.src\n return currentBlockImage\n },\n focusRing: false,\n },\n {\n name: 'left.alt',\n label: 'Left-Hand Image Alt Text',\n component: 'text',\n },\n {\n name: 'right.src',\n label: 'Right-Hand Image',\n component: 'image',\n parse: filename => `/${filename}`,\n uploadDir: () => '/',\n previewSrc: (formValues, input) => {\n const index = input.field.name.split('.')[1]\n const currentBlockImage = formValues.blocks[index].right.src\n return currentBlockImage\n },\n focusRing: false,\n },\n {\n name: 'right.alt',\n label: 'Right-Hand Image Alt Text',\n component: 'text',\n },\n ],\n },\n}\n```\n\n### Passing children with Gatsby Image\n\nBelow is an example of how you could **pass children** as a to `InlineImage` to work with _Gatsby Image_. Notice how _children_ **need to be passed via** [**render props**](https://reactjs.org/docs/render-props.html).\n\nThe return value from the `previewSrc` function is passed as a prop. You can use this as the Img src when the CMS is enabled. This allows it so when new images are uploaded, the correct `previewSrc` should render. A fallback `src` should be provided based on the form data — this will be the `src` when the CMS is disabled.\n\nRead more on [proper image paths](/docs/plugins/fields/image#proper-image-paths-in-gatsby) in Gatsby to get context on the `parse` & `uploadDir` configuration.\n\n```jsx\nimport {\n Inlineform,\n InlineImage,\n InlineTextareaField,\n} from 'react-tinacms-inline'\nimport { useRemarkForm } from 'gatsby-tinacms-remark'\nimport { usePlugin } from 'tinacms'\nimport Img from 'gatsby-image'\n\n// Using InlineImage with Gatsby Image\nexport function Hero({ data }) {\n const [post, form] = useRemarkForm(data.markdownRemark)\n\n usePlugin(form)\n\n return (\n