question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Carousel doesn't work with relative images address

See original GitHub issue

Hi,

Seems the carousel component just working with absolute image address and when i set the direct/relative image address it goes disappear.

the following codes working well,

$('.carousel.carousel-slider').carousel({full_width: true});

<div class="carousel carousel-slider">
    <a class="carousel-item" href="#one!"><img src="http://lorempixel.com/800/400/food/1"></a>
    <a class="carousel-item" href="#two!"><img src="http://lorempixel.com/800/400/food/2"></a>
    <a class="carousel-item" href="#three!"><img src="http://lorempixel.com/800/400/food/3"></a>
    <a class="carousel-item" href="#four!"><img src="http://lorempixel.com/800/400/food/4"></a>
</div>

But when i change the image address to relative the carousel no longer show.

$('.carousel.carousel-slider').carousel({full_width: true});

<div class="carousel carousel-slider">
    <a class="carousel-item" href="#one!"><img src="assets/images/slide2.jpg"></a>
    <a class="carousel-item" href="#two!"><img src="assets/images/slide2.jpg"></a>
    <a class="carousel-item" href="#three!"><img src="assets/images/slide2.jpg"></a>
    <a class="carousel-item" href="#four!"><img src="assets/images/slide2.jpg"></a>
</div>

JFYI, the images address are correct and images loading correct but the .carousel.carousel-slider have wrong height.

.carousel.carousel-slider {
    top: 0;
    left: 0;
    height: 0;
}
<div class="carousel carousel-slider">
            <div class="carousel-item" style="z-index: 0; opacity: 1; transform: translateX(0px) translateX(0px) translateX(0px) translateZ(0px);">
                <div class="row">
                    <h4>Test</h4>
                    <h5>Test</h5>
                    <div class="col l6">
                        <p> Test  </p>
                    </div>
                    <div class="col l6">
                        <img src="./assets/images/slide2.jpg">
                    </div>
                </div>
            </div>
        </div>

So I’ve tested following address structure,

./assets/images/slide2.jpg -> doesn’t work

/assets/images/slide2.jpg -> Doesn’t work

assets/images/slide2.jpg -> doesn’t work

so I’ve added the random number as a parameter to end of above link to avoiding the cache issue.

./assets/images/slide2.jpg?555576 -> doesn’t work

but when i using the absolute url for image it goes resolve,

http://example.com/assets/images/slide2.jpg -> **Workin’ welllllll!!! 😐 ** example.com/assets/images/slide2.jpg Doesn’t work www.example.com/assets/images/slide2.jpg Doesn’t work

it’s better that i say the carousel component just working with http/https protocol image address.😐 So the slider component working well with both address method and all above address.

finalize, I haven’t any issue on the browser console.

Please advice.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:14 (1 by maintainers)

github_iconTop GitHub Comments

9reactions
samyiliascommented, Jul 27, 2019

here is a quick css fix : // in your custom css file

  min-height: 40vh !important  (or whatever hight you need)
3reactions
mikekedacommented, Feb 25, 2017

@kmmbvnr I debugged this, sometimes load event isn’t triggered. I solved this with my custom js (before carousel initialization):

$(‘.carousel.carousel-slider’).each(function() { var view = $(this); var firstImage = view.find(‘.carousel-item img’).first(); var imageHeight = firstImage[0].naturalHeight; if (imageHeight > 0) { view.css(‘height’, imageHeight / firstImage[0].naturalWidth * view.width()); } else { view.css(‘height’, 400); } });

P.S. I think the problem isn’t in relative images address, for me the bug was in 40% page loads for relative image address and 20% with absolute image address.

Read more comments on GitHub >

github_iconTop Results From Across the Web

My Image Carousel is not working? (HTML & CSS)
I am trying to make an Image Carousel for a website, I coded the thing in brackets, which shows in the brackets live...
Read more >
Relative path in Carousel - Material Design for Bootstrap
p><strong>Expected behavior</strong> show carousel images</p> ... This relative path doesn't work as it's used from within a component inside a library.
Read more >
Carousel · Bootstrap v4.6
The carousel is a slideshow for cycling through a series of content, built with CSS 3D transforms and a bit of JavaScript. It...
Read more >
Problem Carousel-block after update - WordPress.org
After updating CoBlocks to 2.20 (and still on WP 5.8.3), the carousel has broken. It shrunk the images to thumbnail size spaced far...
Read more >
Creating an Accessible Image Carousel
Learn how to build an accessible image carousel that supports multiple input modes and is progressively enhanced with CSS scroll snap and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found