vasilis 123
vasilis 123

Reputation: 665

gatsby does not fetch all media items from wordpress CMS

I am using gatsby with wordpress as a headless CMS to grab all media images and display them on a gatsby page . However out of the 3 images I have uploaded on wordpress only two are fetched to gatsby using graphql .

My graphql query inside a react component:

  const data = useStaticQuery(graphql`
    query MediaQuery {
    
      allWpMediaItem {
        nodes {
          localFile {
            childImageSharp {
              id
              gatsbyImageData(
                height: 700, 
                width: 900 ,
                placeholder: BLURRED , 
                quality:100,
                formats:AUTO,
                transformOptions: {fit:COVER}
              )
            }
          }
        }
      }

    }
  `);

I tried deleting the cache folder in gatsby and restarting with gatsby develop but the result is the same .

My images are unattached on wordpress and I do not think this is the problem as I have toggled the feature and still get the second and third image .

enter image description here

I would appreciate your help .

Upvotes: 0

Views: 589

Answers (1)

RiddMa
RiddMa

Reputation: 46

Hi it's over a year now but I encountered the same problem when building my Gatsby site, after googling and digging the docs, I found the solution that works for my case, it's stupidly simple! >_<

The official doc says that ONLY REFERENCED media items are sourced, and currently there is no way to pull all Media Items. That's all.....Should've read the doc more carefully, literally wasted hours on solving this.

So I published a new post including the missing image, my running npm run dev console says it's pulling changes, and now running the GraphQL query again the image shows up.


edit:

sometimes updating existing post does not trigger gatsby-source-wordpress update, rerun npm run dev helps.

Upvotes: 3

Related Questions