Created
February 7, 2015 18:37
-
-
Save JayWood/eb98214567a169b7b80b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if( $images ): ?> | |
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel"> | |
<!-- Indicators --> | |
<ol class="carousel-indicators"> | |
<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li> | |
<li data-target="#carousel-example-generic" data-slide-to="1"></li> | |
<li data-target="#carousel-example-generic" data-slide-to="2"></li> | |
</ol> | |
<!-- Wrapper for slides --> | |
<div class="carousel-inner" role="listbox"> | |
<?php | |
// Set a temporary iterator. | |
$tmp_num = 0; | |
?> | |
<?php foreach ( $images as $image ) { | |
$url_large = $image['sizes']['large']; | |
// Basically if our iterator is 0, we're on the first | |
// slide, so set the class to active, if not, set it to empty. | |
$class = $tmp_num == 0 ? ' active' : ''; | |
?> | |
<div class="item <?php echo $class; ?>"> | |
<img src="<?php echo $url_large ?>" class="img-responsive" alt="img" /> | |
</div> | |
<?php | |
$tmp_num++; | |
} | |
?> | |
</div> | |
<!-- Controls --> | |
<a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev"> | |
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span> | |
<span class="sr-only">Previous</span> | |
</a> | |
<a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next"> | |
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span> | |
<span class="sr-only">Next</span> | |
</a> | |
</div> | |
<?php endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment