Skip to content
This repository has been archived by the owner on Aug 30, 2018. It is now read-only.

Commit

Permalink
Merge pull request #165 from Shopify/iframe-sizing
Browse files Browse the repository at this point in the history
Responsive iframes for youtube and vimeo
  • Loading branch information
cshold committed Aug 4, 2014
2 parents e8a756c + 4920d5b commit 015dc42
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
6 changes: 6 additions & 0 deletions assets/shop.js.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ timber.init = function () {
timber.cacheSelectors();
timber.accessibleNav();
timber.productImageSwitch();
timber.responsiveVideos();
}

timber.accessibleNav = function () {
Expand Down Expand Up @@ -115,5 +116,10 @@ timber.productImageSwitch = function () {
});
}

timber.responsiveVideos = function () {
$('iframe[src*="youtube.com/embed"').wrap('<div class="video-wrapper"></div>');
$('iframe[src*="player.vimeo"').wrap('<div class="video-wrapper"></div>');
}

// Initialize Timber's JS on docready
$(timber.init)
25 changes: 23 additions & 2 deletions assets/timber.scss.liquid
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*============================================================================
Shopify Timber v1.3.1
Shopify Timber v1.3.2
Copyright 2014 Shopify Inc.
Author Carson Shold @cshold
Built with Sass - http://sass-lang.com/
Expand Down Expand Up @@ -1180,10 +1180,31 @@ svg:not(:root) {
}

img.auto,
.grid-item img,
.grid-item img {
max-width: 100%;
max-height: 100%;
height: auto;
}

.grid-item iframe {
max-width: 100%;
}

.video-wrapper {
position: relative;
overflow: hidden;
max-width: 100%;
padding-bottom: 56.25%;
height: 0;
height: auto;

iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
}


Expand Down

0 comments on commit 015dc42

Please sign in to comment.