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

Minor Video Embed Optimization #958

Merged
merged 2 commits into from
Mar 16, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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