When querying featured media from wordpress posts, some images get their corresponding localFile node created but others do not, giving me a localFile = null. Weirdest thing is this error occurs on different sets of images on development and production (netlify).
The graphql query I'm using to get the posts data:
query {
allWordpressPost(sort: { fields: [date] , order: DESC }, limit: 10) {
edges {
node {
id
title
date
featured_media {
id
source_url
localFile {
id
childImageSharp {
fixed(width: 400, height: 400) {
...GatsbyImageSharpFixed
}
}
}
}
}
}
}
}
My wordpress plugin config inside gatsby-config.js:
{
resolve: "gatsby-source-wordpress",
options: {
baseUrl: "iq.tlahtolli.com",
protocol: "https",
}
}
I've also prepared a public repo which reproduces this exact problem.
I should have node.featured_media = null for posts with no featured media, I have no problem with that, but I expect posts that do to have the corresponding image, to have it available as localFile.
localFile is null for posts that have featured media.
Old issues will be closed after 30 days of inactivity. This issue has been quiet for 20 days and is being marked as stale. Reply here or add the label "not stale" to keep this issue open!
Hey again!
It鈥檚 been 30 days since anything happened on this issue, so our friendly neighborhood robot (that鈥檚 me!) is going to close it.
Please keep in mind that I鈥檓 only a robot, so if I鈥檝e closed this issue in error, I鈥檓 HUMAN_EMOTION_SORRY. Please feel free to reopen this issue or create a new one if you need anything else.
Thanks again for being part of the Gatsby community!
Did you ever find a solution here? I am seeing the same issue for gatsby-source-shopify. Can't tell if it's because my internet is bad right now and failing to download the images or what.
I found two issues leading to this error :
For more investigation, you can add a console log in gatsby-source-wordpress downloadMediaFiles method in normalize.js file :
if (!fileNodeID) {
try {
const fileNode = await createRemoteFileNode({
url: e.source_url,
store,
cache,
createNode,
createNodeId,
parentNodeId: e.id,
auth: _auth,
reporter
});
if (fileNode) {
fileNodeID = fileNode.id;
await cache.set(mediaDataCacheKey, {
fileNodeID,
modified: e.modified
});
}
} catch (e) {// Ignore
console.log(e) // ---------------- add this -----------------
}
}
}
It allowed me to find the wrong url: http.... error
@LoicUV thanks! Not sure which problem I had exactly but re-uploading the media on WordPress worked.
Same problem here and this happens with random images, there is no pattern.
I had so many images so i had to run npm run develop multiple times to get all the images
Most helpful comment
I found two issues leading to this error :
For more investigation, you can add a console log in gatsby-source-wordpress
downloadMediaFilesmethod innormalize.jsfile :It allowed me to find the
wrong url: http....error