Skip to content

Instantly share code, notes, and snippets.

@ms-studio
Created December 11, 2017 21:51
Show Gist options
  • Save ms-studio/739396e91efeef2788687c96c7d8953c to your computer and use it in GitHub Desktop.
Save ms-studio/739396e91efeef2788687c96c7d8953c to your computer and use it in GitHub Desktop.
Improve Slideshare embedding - Make that iframe exactly the right size!
/*
* Improve Slideshare embedding
* Make that iframe exactly the right size!
*/
$(".entry-content p iframe[src*='https://www.slideshare']").each(function() {
var $this = $(this);
var slideW = $this.attr('width');
var slideH = $this.attr('height');
var slideRatio = (slideH / slideW);
var itemW = $this.width();
var idealH = itemW*slideRatio;
// calculate max height: window - nav bar...
var maxH = ( $(window).height() - 162);
if ( idealH > maxH ){
$this.css( "height", maxH );
// console.log("applied maxHeight: "+maxH);
} else {
$this.css( "height", idealH );
// console.log("applied idealHeight: "+idealH);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment