Skip to content
This repository has been archived by the owner on Apr 20, 2021. It is now read-only.

Stop all medias to be downloading ? #150

Closed
JimCaignard opened this issue Sep 5, 2020 · 10 comments · Fixed by #413
Closed

Stop all medias to be downloading ? #150

JimCaignard opened this issue Sep 5, 2020 · 10 comments · Fixed by #413
Labels
documentation Improvements or additions to documentation

Comments

@JimCaignard
Copy link

Hi all,

i'm using this plugin with a large media website and so i use a CDN for all images and i'would like to
stop downloading all the media at every build as i'm not using them at all..

I find the option to disable gatsby image but not to stop the downloading..

Ideas ?

@TylerBarnes
Copy link
Collaborator

Hi @JimCaignard ,
We've been talking about adding this as an option along with some additional helpers to still use the Gatsby Img React component, but nothing has materialized yet.

What you can try in the meantime to stop the downloading from happening is to override the type option on MediaItem nodes that downloads the files.

Try this

{
  resolve: `gatsby-plugin-wordpress-experimental`,
  options: {
    type: {
      MediaItem: { beforeChangeNode: () => {} }
    }
  }
}

I'm not entirely sure if there will be any side effects to doing this, but we will definitely be adding a more official API for this after we ship the stable release of this plugin. Thanks for this feature request!

@brandensilva
Copy link

I tried the above suggestions @TylerBarnes but it doesn't seem to make a difference in my case. Is there no way to disable this so I can proceed forward with getting a build working?

@JimCaignard
Copy link
Author

Thanks @TylerBarnes for your work and the solution you gave me !
It was working fine till the version 1.4.1 but now it's not working at all..

Any ideas or other solution to make it works again ?

@TylerBarnes
Copy link
Collaborator

@JimCaignard on the latest version try this config:

{
  resolve: `gatsby-source-wordpress-experimental`,
  options: {
    html: {
      createStaticFiles: false,
      useGatsbyImage: false,
    }
    type: {
      MediaItem: { beforeChangeNode: () => {} }
    }
  }
}

@JimCaignard
Copy link
Author

JimCaignard commented Oct 9, 2020

@TylerBarnes it's not working :

Capture d’écran 2020-10-09 à 12 57 49

it's doing that and never stop..

@TylerBarnes
Copy link
Collaborator

@JimCaignard if you can provide a reproduction or /graphql endpoint URL I can take a look. Thanks

@znwhite
Copy link

znwhite commented Oct 13, 2020

@TylerBarnes I am having similar issue, not sure if it's a duplicate but I've included more info: #228

@YCMitch
Copy link

YCMitch commented Nov 18, 2020

I would absolutely love this. I've been trying to get it running for hours and it always fails when downloading media files. All my media is on a separate CDN too - I can't fathom why Gatsby would need to download it all.

Nothing suggested above it stopping it from doing so. It REALLY wants those images.

For now I'm giving up and going back to trusty ol' gatsby-source-graphql

If it helps, my endpoint is https://atomos.yourcreative.com.au/graphql. It always fails on the same image (although the image is very much valid and exists). Regardless of the error, I just want it to not download/format/do anything with the media items. If it can just skip them, we're in business.

@TylerBarnes
Copy link
Collaborator

TylerBarnes commented Nov 19, 2020

Hey everyone, I just had another look at this and you can achieve it with the following plugin options. I tested it on your endpoint @MitchEff and it works great.

    {
      resolve: `gatsby-source-wordpress-experimental`,
      options: {
        url: process.env.WPGRAPHQL_URL,
        html: {
          createStaticFiles: false,
          useGatsbyImage: false,
        },
        type: {
          MediaItem: { lazyNodes: true },
        },
      },
    },

If you query for MediaItem.localFile it will fetch images, so if you don't want it to fetch images don't query for that field. Cheers :D

@TylerBarnes TylerBarnes added documentation Improvements or additions to documentation and removed enhancement New feature or request todo after v4 release labels Nov 19, 2020
@TylerBarnes
Copy link
Collaborator

Actually, re-opening this so we can make sure we document it in our upcoming documentation push!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants