Skip to content
This repository has been archived by the owner on Sep 16, 2019. It is now read-only.

Commit

Permalink
Merge pull request #958 from EricRihlmann/video-embed
Browse files Browse the repository at this point in the history
Minor Video Embed Optimization
  • Loading branch information
olefredrik authored Mar 16, 2017
2 parents b01f131 + e2ba5d4 commit 38ac289
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions library/foundation.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function foundationpress_active_list_pages_class( $input ) {
endif;

/**
* Enable Foundation responsive videos for oEmbed
* Enable Foundation responsive embeds for WP video embeds
*/

if ( ! function_exists( 'foundationpress_responsive_video_oembed_html' ) ) :
Expand All @@ -115,12 +115,13 @@ function foundationpress_responsive_video_oembed_html( $html, $url, $attr, $post

$is_video = false;

// Determine if oEmbed is a video
// Determine if embed is a video
foreach ( $video_sites as $site ) {
// Match on `$html` instead of `$url` because of
// shortened URLs like `youtu.be` will be missed
if ( strpos( $html, $site ) ) {
$is_video = true;
break;
}
}

Expand All @@ -141,14 +142,15 @@ function foundationpress_responsive_video_oembed_html( $html, $url, $attr, $post

$class = 'responsive-embed'; // Foundation class

// Determine if `widescreen`
// Determine if aspect ratio is 16:9 or wider
if ( is_numeric( $width ) && is_numeric( $height ) && ( $width / $height >= 1.7 ) ) {
$class .= ' widescreen'; // space needed
}

// Wrap oEmbed markup in Foundation responsive embed
return '<div class="' . $class . '">' . $html . '</div>';

} else { // not a supported video oEmbed
} else { // not a supported embed
return $html;
}

Expand Down

0 comments on commit 38ac289

Please sign in to comment.