Git Product home page Git Product logo

Comments (3)

SoumyaSubhrajit avatar SoumyaSubhrajit commented on June 13, 2024

hi , @topengl I may like to suggest 2 way of this issue,

1 ) The image are loading in the sanity db right, then you fetch the image by the url ,
in the client.js this pieces of code -> export const urlFor = (source) => builder.image(source); , now check the url fetching right or it gave some error, by
doing maual checks by await and fetch(), click this url some tutorial reference 👉 []
(https://www.youtube.com/watch?v=cuEtnrL9-H0&pp=ygULYXdhaXQgZmV0Y2g%3D).

  1. In the Product.jsx you do the image loading process remember, <img src={urlFor(image && image[0])} width={250} height={250} className="product-image" alt="" />
    this one is load and resizes the image and make it a container so that I can fetch the
    image and load it outside, then in the [slug.js] , we render out the image for the
    image by small-image-container, right then we iterate the hole image section and
    each of the image have urlFor(item) that gave the image address , and then the
    mouse point to certain image it will set the index value. and we see the change have
    been made in the slug page.
  2. see the code may be it will help you, <div className="small-images-container"> {image?.map((item, i) => ( <img // IF YOU CHANGE THE VALUE OF 'i' THEN THE IMAGE WILL CHANGE ACCORDINGLY.. key={i} src={urlFor(item)} className={i === index ? 'small-image selected-image' : 'small-image'} // THIS IS THE EVENT WHEN THE MOUSEPOINT THE REALTEED OBJECT onMouseEnter={() => setIndex(i)} /> ))}

if you have any further error, or any doubt my happy to help you with it.

from ecommerce_sanity_stripe.

Madzeedy avatar Madzeedy commented on June 13, 2024

Hey topengl check on the first lines where you're declaring your class ProductDetails, you might be missing curly braces parameters. Keep it up Buddy

from ecommerce_sanity_stripe.

khalilpyh avatar khalilpyh commented on June 13, 2024

My code is like this
<img src={urlFor(image && image.length > 1 ? image[index] : image[0])} className="product-detail-image" />

from ecommerce_sanity_stripe.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.