Last active
August 29, 2015 14:07
-
-
Save jonwilcox/185db78250ac4c432b2c to your computer and use it in GitHub Desktop.
Add News Story Featured Video
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
$('.lw_related_url:contains("YouTube Video")').each(function(){ // Get any related content links that contain the text "YouTube Video" | |
var link = $(this).find('a').attr('href'); // Get the href of the YouTube Link | |
var ID = RegExp('[?&]v=([^&]*)').exec(link)[1]; // Use a regular expression to get the video ID from the 'v' parameter | |
var $iframe = $('<iframe width="700" height="394" src="https://www.youtube.com/embed/'+ID+'" frameborder="0" allowfullscreen></iframe>'); // construct an iframe using the video ID | |
$('.news_image').addClass('video').prepend($iframe).fitVids(); // Add a class of 'video' to the .news_image div, prepend the iframe, and run fitvids on it | |
if($('.lw_related_url').length == 1) { // if that was the only link in the related content section | |
$('.related_content').remove(); // remove the whole section | |
} else { | |
$(this).remove(); // otherwise just remove that link | |
} | |
}) |
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
// hide the slideshow that would otherwise show on the page | |
.news_image.video .lw_slideshow_wrapper { | |
display: none; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment