Carousel shows no photo

Asked

Viewed 44 times

1

Well, I have a carousel where I pick up the "images" (actually it’s just the names of the images) in the database and I do a foreach on the carousel but the images don’t appear. When I display the source code I see that the images are embedded in the pages and they see on the page no more shows the images on the carousel. What could be?

My merry-go-round:

<div id="content">
<div class="container no-padding">
    <div class="row">
        <!-- Carousel Slideshow -->
        <div id="carousel-example" class="carousel slide" data-ride="carousel">
            <!-- Carousel Indicators -->
            <ol class="carousel-indicators">
                <li data-target="#carousel-example" data-slide-to="0" class="active"></li>
                <li data-target="#carousel-example" data-slide-to="1"></li>
                <li data-target="#carousel-example" data-slide-to="2"></li>
            </ol>
            <div class="clearfix"></div>
            <!-- End Carousel Indicators -->
            <!-- Carousel Images -->

            <?php
                foreach ($imagem as $value) {
                    if ($value->imagem_status == true) {?>
                        <div class="item">
                            <img src="<?php echo base_url('tema/assets/img/site/'.$value->imagem_link) ?>">
                        </div>

                  <?php }
                }
            ?>



            </div>
            <!-- End Carousel Images -->
            <!-- Carousel Controls -->
            <a class="left carousel-control" href="#carousel-example" data-slide="prev">
                <span class="glyphicon glyphicon-chevron-left"></span>
            </a>
            <a class="right carousel-control" href="#carousel-example" data-slide="next">
                <span class="glyphicon glyphicon-chevron-right"></span>
            </a>
            <!-- End Carousel Controls -->
        </div>
        <!-- End Carousel Slideshow -->
    </div>
</div>

I wonder if you have a solution for that.

1 answer

1


I have an example that I use here and works normal, the only thing that seems to be missing is in div of the picture one class="active item" why the carousel needs to have a div with an active class.

Follow the example I have:
`

        <!-- Wrapper for slides -->
        <div class="carousel-inner" role="listbox">
            <?php foreach($slider as $slide):?>
            <div <?php echo ($slide->class == 1)?"class='item active ctrl'":"class='item ctrl'"?>>
                <img src="<?php echo base_url('images/slider/'.$slide->image);?>" alt="Destaques">
                <div class="carousel-caption">
                    <h3><?php echo $slide->titulo; ?></h3>
                </div>
            </div>
            <?php endforeach; ?>
        </div>`
  • And this variable class is what? $slide->class

  • this is a simplified if is the same thing as doing: if($slide->class == 1){&#xA; echo "<div class='item active ctrl'>";&#xA;}else{&#xA; echo "<div class='item ctrl'>";&#xA;} The class variable comes from the bank with value 1 or 0 to define which slide will be the first asset.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.