Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is the best approach for someone with thousands of images? #26995

Closed
jasonbiondo opened this issue Sep 22, 2020 · 9 comments
Closed

What is the best approach for someone with thousands of images? #26995

jasonbiondo opened this issue Sep 22, 2020 · 9 comments
Labels
type: documentation An issue or pull request for improving or updating Gatsby's documentation type: question or discussion Issue discussing or asking a question about Gatsby

Comments

@jasonbiondo
Copy link

Summary

I have a shopify store with over 10,000 images and when I try to use gatsby-image the query takes too long to run. In this situation should people be using gatsby-image or should they be using another lazyloading library? What is the best approach for someone with thousands of images on a CDN like shopify? I didn't see this outlined in the docs so I want to ask.

@jasonbiondo jasonbiondo added the type: documentation An issue or pull request for improving or updating Gatsby's documentation label Sep 22, 2020
@gatsbot gatsbot bot added type: question or discussion Issue discussing or asking a question about Gatsby status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Sep 22, 2020
@KyleAMathews
Copy link
Contributor

You can use image processing tools like Cloudinary to offload image process e.g. https://cloudinary.com/blog/how_to_improve_your_shopify_s_store_loading_times_using_cloudinary

You can still use gatsby-image with Cloudinary as you can create a component which generates the cloudinary URLs for all the different URLs that gatsby-image expects as props e.g.

<CloudinaryImage
  src="some-product-image"
  fluid
  maxWidth={800}
/>

@jasonbiondo
Copy link
Author

jasonbiondo commented Sep 22, 2020

@KyleAMathews Does this CloudinaryImage component already exist? Also, regardless of cloudinary for optimization, shopify already has the images on a CDN, why can't I just use those URLs?

@KyleAMathews
Copy link
Contributor

There's this — https://cloudinary.com/blog/introducing_cloudinary_s_gatsby_plugins

You absolutely can use the images directly from Shopify — the only issue I believe is that Shopify doesn't optimize the images for you so if e.g. you upload a very large image for a product, it'll load very slowly. Image processing + gatsby-image solves that problem for you.

@jasonbiondo
Copy link
Author

jasonbiondo commented Sep 23, 2020

Cool, but my main issue is not the image optimization itself, but that fact that the query is heavy and seems to try and store the files locally via

query MyQuery { allShopifyProduct(sort: {fields: [title]}) { edges { node { metafields { key value } title shopifyId description handle priceRange { minVariantPrice { amount } } images { localFile { childImageSharp { fluid(maxWidth: 500, jpegQuality: 100) { ...GatsbyImageSharpFluid_withWebp_tracedSVG } } } } } } } }

Is there a way to just use gatsby-image with just the CDN url instead of how I have it in the query above? I didn't see this in the documentation and I sure would love it so that I can use it with my prismic image urls as well.

@KyleAMathews
Copy link
Contributor

I'm not very familiar with the Shopify API or the source plugin. You could explore in graphiql if the CDN file is available. It does look like we don't query it —

id
altText
originalSrc
— I assume the Shopify API has the link to the original URL so you could PR adding it to the source plugin so it's available to query instead of localFile.

@jasonbiondo
Copy link
Author

jasonbiondo commented Sep 23, 2020 via email

@ascorbic ascorbic removed the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Sep 23, 2020
@KyleAMathews
Copy link
Contributor

These are the proptypes —

const fixedObject = PropTypes.shape({
width: PropTypes.number.isRequired,
height: PropTypes.number.isRequired,
src: PropTypes.string.isRequired,
srcSet: PropTypes.string.isRequired,
base64: PropTypes.string,
tracedSVG: PropTypes.string,
srcWebp: PropTypes.string,
srcSetWebp: PropTypes.string,
media: PropTypes.string,
})
const fluidObject = PropTypes.shape({
aspectRatio: PropTypes.number.isRequired,
src: PropTypes.string.isRequired,
srcSet: PropTypes.string.isRequired,
sizes: PropTypes.string.isRequired,
base64: PropTypes.string,
tracedSVG: PropTypes.string,
srcWebp: PropTypes.string,
srcSetWebp: PropTypes.string,
media: PropTypes.string,
maxWidth: PropTypes.number,
maxHeight: PropTypes.number,
})

Both the fixed & fluid prop take a src key.

@LekoArts
Copy link
Contributor

I think the initial question was answered, for a better CDN story you can follow: #23724

If it's about the general performance I merged this to: #26726

@mrhut10
Copy link

mrhut10 commented Jan 4, 2021

hay everyone here I'm the co-author PR #23840 which address issue #23724 we've had no luck getting it merged.
anyone that wants to see that feature though could you please express your desire/problems on that merge request or its related issue.

and as its been a while next week I will bring it back up to current with master and retest it locally with a demo project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: documentation An issue or pull request for improving or updating Gatsby's documentation type: question or discussion Issue discussing or asking a question about Gatsby
Projects
None yet
Development

No branches or pull requests

5 participants