contentful-userland / gatsby-contentful-starter

Gatsby starter for a Contentful project from the community.
https://contentful-userland.github.io/gatsby-contentful-starter/
MIT License
279 stars 122 forks source link

Download images locally #54

Open ghost opened 5 years ago

ghost commented 5 years ago

Is it possible to download images locally and server them via custom domain?

bit-crafter commented 4 years ago

Hi @LittleHamster, you can try this Download assets for static distribution

Enable this feature with the downloadLocal: true option.

ghost commented 4 years ago

@tumdav was this recently updated?

ghost commented 4 years ago

I set this to true but images are still loaded via their domain, any ideas?

raubin commented 4 years ago

I tried to use this config setting as well and it did not pull down Contentful images. I verified by checking the static assets folder after build. In my case I was trying to pull embedded assets for Rich Text fields and Markdown Long Text fields. I did not try with separate media fields.

bit-crafter commented 4 years ago

I set this to true but images are still loaded via their domain, any ideas?

@LittleHamster you have to query files on this way

  query BlogPostBySlug($slug: String, $locale: String) {
    contentfulBlogPost(slug: { eq: $slug }) {
      title
      publishDate(formatString: "MM/DD/YYYY")
      image {
        localFile {
          childImageSharp {
            fluid(maxWidth: 1180) {
              ...GatsbyImageSharpFluid_withWebp_noBase64
            }
          }
        }
      }
      body {
        childMarkdownRemark {
          html
        }
      }
    }
  }
bit-crafter commented 4 years ago

I tried to use this config setting as well and it did not pull down Contentful images. I verified by checking the static assets folder after build. In my case I was trying to pull embedded assets for Rich Text fields and Markdown Long Text fields. I did not try with separate media fields.

maybe you can find something helpful here