Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save celticwebdesign/41815097f67f316ac2b0b6a5b00ca0ee to your computer and use it in GitHub Desktop.
Save celticwebdesign/41815097f67f316ac2b0b6a5b00ca0ee to your computer and use it in GitHub Desktop.
Using WordPress - Advance Custom Fields Pro
<?php
$rows_hfbir = get_field('homepage_full_browser_images_repeater');
if($rows_hfbir) {
$images_array = array();
foreach($rows_hfbir as $row_hfbir) {
$image_attributes = wp_get_attachment_image_src( $row_hfbir['homepage_full_browser_image_single'], 'full' );
array_push($images_array, $image_attributes[0]);
}
$images_json = json_encode($images_array);
}
?>
<section id='home-full-screen' class=' clear' role='main' data-homepage-image='<?php echo $images_json; ?>'>
</section>
jQuery
/*
Finds the viewport width
http://matanich.com/test/viewport-width/
*/
(function(n){n.viewportSize={},n.viewportSize.getHeight=function(){return t("Height")},n.viewportSize.getWidth=function(){return t("Width")};var t=function(t){var f,o=t.toLowerCase(),e=n.document,i=e.documentElement,r,u;return n["inner"+t]===undefined?f=i["client"+t]:n["inner"+t]!=i["client"+t]?(r=e.createElement("body"),r.id="vpw-test-b",r.style.cssText="overflow:scroll",u=e.createElement("div"),u.id="vpw-test-d",u.style.cssText="position:absolute;top:-1000px",u.innerHTML="<style>@media("+o+":"+i["client"+t]+"px){body#vpw-test-b div#vpw-test-d{"+o+":7px!important}}<\/style>",r.appendChild(u),i.insertBefore(r,e.head),f=u["offset"+t]==7?i["client"+t]:n["inner"+t],i.removeChild(r)):f=n["inner"+t],f}})(this);
(function ($, root, undefined) {
$(function () {
'use strict';
var width = viewportSize.getWidth();
var height = viewportSize.getHeight();
homeFullScreen();
$( window ).resize(function() {
width = viewportSize.getWidth();
height = viewportSize.getHeight();
homeFullScreen();
});
function homeFullScreen() {
var $browser_height = height;
$('#home-full-screen').height($browser_height);
}
if( $("#home-full-screen").length > 0 ) {
$("#home-full-screen").backstretch( $("#home-full-screen").data('homepage-image'), {duration: 4000, fade: 750} );
}
});
})(jQuery, this);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment