-
-
Notifications
You must be signed in to change notification settings - Fork 43
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
Remote images in gatsby-image #35
Comments
👋 There is an example in the |
import React from 'react'
import Layout from '../components/layout.js'
import { Seo } from '../components/Seo'
import { graphql } from 'gatsby'
import Img from 'gatsby-image'
import Pagetitle from '../components/Pagetitle'
import styled from 'styled-components'
const Article = styled.article``
const Eventdate = styled.h4``
const Content = styled.div``
const Image = styled.div`
max-width: 600px;
`
const EventListing = ({ data }) => {
const events = data.airtable.data
const seotitle = events.title + ' | In Sowerby Bridge The Town and Business Guide For Residents and Visitors'
return (
<Layout>
<Article>
<Seo title={seotitle} />
<Pagetitle title={events.title} />
<Eventdate>{events.displaydate}</Eventdate>
<Content
dangerouslySetInnerHTML={{
__html: events.content.childMarkdownRemark.html,
}}
/>
<Image>{events.eventimage && <Img alt={events.title} fluid={events.eventimage.localFiles[0].childImageSharp.fluid} />}</Image>
</Article>
</Layout>
)
}
export const aireventgraph = graphql`
query aireventquery($slug: String!) {
airtable(table: { eq: "Events" }, data: { slug: { eq: $slug } }) {
id
data {
title
displaydate
content {
id
childMarkdownRemark {
html
}
}
eventimage {
localFiles {
id
childImageSharp {
fluid(maxWidth: 500) {
...GatsbyImageSharpFluid
}
}
}
}
}
}
}
`
export default EventListing
gatsby config :
{
baseId: `appEsfKlCG88mTbFU`,
tableName: `Events`,
tableView: `Published`,
queryName: `Published Events`, // optional
mapping: { content: 'text/markdown', eventimage: `fileNode` },
// can leave off queryName, mapping or tableLinks if not needed
},
{
baseId: `appEsfKlCG88mTbFU`,
tableName: `Events`,
tableView: `Archived`,
queryName: `Archived Events`, // optional
mapping: { content: 'text/markdown', eventimage: `fileNode` },
// can leave off queryName, mapping or tableLinks if not needed
},
Regards
Paul Kidd
Thunderfix
…________________________________
From: dtbaker <notifications@github.com>
Sent: Monday, January 21, 2019 12:41 pm
To: jbolda/gatsby-source-airtable
Cc: Subscribed
Subject: [jbolda/gatsby-source-airtable] Remote images in gatsby-image (#35)
Hello,
Does anybody have a working example of pulling in remote image URLs from Airtable and making them available within gatsby-image (i.e. for lazy loading / optimization etc..)
Thanks!
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub<#35>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AL62etep09LZjpou40xwrum09CyYE_viks5vFbWEgaJpZM4aKv1Y>.
|
Thanks @jbolda - I can only see Thank you @waywardm - how does |
I have made progress with this. A custom
and then query the local file like so:
and then attempting to load the image on the page:
|
We would happily take a pull request clarifying the docs / examples once you figure this out so it does not trip up others in the future. 👍 In the config, you need to note which column in Airtable takes attachments, as shown here. Then you query much like your plugin above does, as shown here, and use it with gatsby-image much like you normally would. Hopefully that helps clarify. |
Hi @dtbaker, Thanks for sharing your little workaround to add images to the In a table called
Then this query returns to me the images, with all the cool juice from the
@jbolda One information I'm struggling to get is: Which Airtable spreadsheet is the parent of the image? Right now I get all of the images back as one blob of undifferentiated data, as followed. I'm pulling images from different tables and I would need a way to filter them in my page queries so that they can be displayed on the right page. Any insight on that? Thanks buddy 🙂
|
It's available directly attached to each record. See https://github.com/jbolda/gatsby-source-airtable/blob/master/examples/recipes-with-photos/src/templates/recipeTemplate.js#L154 and the related config https://github.com/jbolda/gatsby-source-airtable/blob/master/examples/recipes-with-photos/gatsby-config.js#L28 |
@dtbaker were you able to figure out how to use this Airtable source to query directly instead of making your own nodes? |
Thanks for your answer @jbolda, my question was more about the table name, not the column name. What you call I'm pulling images from two different tables, for two different pages on my website. Both of these tables have a
All the images get successfully imported in the node data layer during build, but I can't find a way to tell which image comes from which table once imported. Any idea ? I hope this is clearer 😄 |
Are you specifically looking to query through
|
Thanks for that @jbolda 🙂 I wanted to use Also, I tried to run your query but it doesn't work on my end (after clearing the cache restarting the server). Once the images are downloaded through your plugin, they become "query-able" through Here's my setup:
The query runs in
Add the
So this is why I wanted to use Thanks again for your help, I really appreciate! |
Hmm, it should work through the Airtable query. It sounds like you may be hitting the upstream bug in this issue? What version of Could that be what tripped @dtbaker up as well? |
There you go @jbolda 🙂
Is this why I got an issue? |
@CharlyMartin this will, every time you install give you the latest |
Here's some of my
Is this more helpful @jbolda? |
It does! Hmm, it looks like 2.0.12 might have been where I noticed an issue. Ref the changelog: https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-source-filesystem/CHANGELOG.md You aren't on the latest, but I think it should be fixed on that version. Any way you can upload a reproduction of the issue? The examples appear to be working. I do need to update my personal site though where I noticed the issue. |
Alright thanks @jbolda! The links in the changelog return a 404 on my side. So updating to 2.20 should solve this problem? Not sure what you mean by "upload a reproduction of the issue"? |
This issue has been automatically marked as stale because it has not had any recent activity for 30 days. It will be closed if no further activity occurs within 7 days. Remove stale label, comment, and/or apply "ongoing issue" label to prevent this from being closed. Thank you for your contributions. |
Cant't see remote images there. |
Hello,
Does anybody have a working example of pulling in remote image URLs from Airtable and making them available within gatsby-image (i.e. for lazy loading / optimization etc..)
Thanks!
The text was updated successfully, but these errors were encountered: