8

JavaScript and I am loading random images from https://picsum.photos but it is not working. Note that for now, I do not want to use the new image optimization in next.js. Local images are working but external images are not working. Below is my code and my next.config.js

<Slider
            {...settingsThumbs}
            asNavFor={nav1}
            ref={slider => setSlider2(slider)}
          >
            {slidesData.map(slide => (
              <div className='slick-slide' key={slide.id}>
                <img
                  className='slick-slide-image'
                  src={`https://picsum.photos/800/400?img=${slide.id}`}
                  alt='sfd'
                />
              </div>
            ))}
          </Slider>

below is my next.js config

module.exports = {
  images: {
    domains: ['https://picsum.photos/']
  }
};

1
  • What does not working mean? What does your network tab in the inspector tell you about the loading of the images? What does the rendered markup look like? Commented Jan 24, 2021 at 21:09

1 Answer 1

17

Per the docs, the domain does not appear to need a protocol (https or http) in front of it. Try

module.exports = {
  images: {
    domains: ['picsum.photos']
  }
};

I also suspect you have an error like the following in your console, going off this source code:

domains value must follow format { domain: 'picsum.photos', ... }. See more info here: https://err.sh/next.js/invalid-i18n-config`

Note: Modifications to the next.config.js file may sometimes require to to restart the dev server before they take effect.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.