gatsbyjs / gatsby-source-wordpress-experimental

The upcoming v4 of gatsby-source-wordpress, currently in beta
MIT License
385 stars 100 forks source link

wpMediaItem for PDF files is null when building for production #343

Closed chrispytoes closed 3 years ago

chrispytoes commented 3 years ago

I have PDFs in my WordPress media library that I'd like to download and serve from the Gatsby site. Everything works in development mode, but when building for production, wpMediaItem comes back null on PDF files.

Here is my query:

query DiscountForms {
  list: wpMediaItem(localFile: {name: {eq: "k3vac-veterans-discount-2020"}}) {
    localFile {
      publicURL
    }
  }
  merchant: wpMediaItem(localFile: {name: {eq: "merchant-enrollment-form"}}) {
    localFile {
      publicURL
    }
  }
}

The query execution succeeds without errors, but the result that comes back in production mode is:

{
  list: null,
  merchant: null
}

Image queries still seem to work fine, it's only PDF files. Could it be that the plugin assumes all media files are images and is trying to compress/optimize them?