Created
August 9, 2015 09:26
-
-
Save celticwebdesign/029eed84db81553c0d48 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
HTML ---- | |
<?php | |
// slideshow | |
$rows = get_field('slideshow_repeater'); | |
if($rows) { | |
echo "<!-- slideshow --> | |
<div id='slideshow' class='full-width clearfix'> | |
<div class='flexslider clearfix'>"; | |
echo "<ul class='slides'>"; | |
foreach($rows as $row) { | |
echo "<li class='slide'>"; | |
$image_attributes = wp_get_attachment_image_src( $row['slide'], 'slideshow-main' ); | |
$alt_text = get_post_meta( $row['slide'], '_wp_attachment_image_alt', true); | |
echo "<img src='".$image_attributes[0]."' alt='".$alt_text."'>"; | |
echo "</li>"; | |
} | |
echo "</ul>"; | |
echo "</div> | |
</div> | |
<!-- /slideshow -->"; | |
} | |
// slideshow | |
?> | |
HTML ---- | |
JS ---- | |
$(window).load(function(){ | |
if( $('.home .flexslider').length > 0 ) { | |
$('.flexslider').flexslider({ | |
animation: "fade", | |
slideshowSpeed: 5000, | |
controlNav: false, | |
directionNav: false, | |
slideshow: true, | |
prevText: "", | |
nextText: "" | |
}); | |
} | |
// Slideshow vertically centralises the slide in the parent li | |
adjustHeight(); | |
$(window).resize(adjustHeight); | |
function adjustHeight() { | |
var $li_height = $('#slideshow.full-width li.flex-active-slide').innerHeight(); | |
var $slide_image_height = $('#slideshow.full-width li.flex-active-slide img').innerHeight(); | |
if( $slide_image_height > $li_height ) { | |
$('#slideshow.full-width li.flex-active-slide img').css('margin-top', -($slide_image_height - $li_height)/2+'px'); | |
} | |
} | |
// Slideshow vertically centralises the slide in the parent li | |
}); | |
JS ----- | |
CSS ---- | |
/*------------------------------------*\ | |
Flexslider - slideshow | |
\*------------------------------------*/ | |
#slideshow {} | |
#slideshow.full-width { | |
max-height:700px; /* Change height as needed */ | |
position: relative; | |
} | |
#slideshow.full-width .flexslider { | |
position: static; | |
} | |
#slideshow.full-width .flexslider li { | |
max-height: 700px; /* Change height as needed */ | |
overflow:hidden; | |
} | |
#slideshow img { | |
width:100%; | |
max-width: auto; | |
} | |
/*------------------------------------*\ | |
Flexslider - slideshow | |
\*------------------------------------*/ | |
CSS ---- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment