开发者 | jamie3d |
---|---|
更新时间 | 2016年12月9日 13:03 |
PHP版本: | 3.3 及以上 |
WordPress版本: | 4.3.1 |
版权: | GPLv3 |
1.2.2
it contains English, Portuguese (BR), and Spanish translations.
See a live demo here: Fluid Video Embeds Demo
Requirements: PHP5+, WordPress 3.3+
Usage: Install the plugin, activate it, then your YouTube and Vimeo embeds should start to ignore the setting in Settings > Media > Maximum embed size
You don't need to use embed code or a shortcode, you can simply paste the YouTube or Vimeo URL into your post and it should work.
You can also use the [fve]
shortcode:
[fve]http://youtu.be/oHg5SJYRHA0[/fve]
If you want to use the Fluid Video Embeds method in a php template file in your theme, you can use the do_shortcode method:
You can filter the YouTube and or Vimeo URLs like this if you want to customize them (like explicitly specifying the https scheme):
// Filter the iframe URL for Vimeo
add_filter( 'fve_vimeo_iframe_url', 'fve_vimeo_iframe_url', 10, 2 );
function fve_vimeo_iframe_url( $vimeo_iframe_url, $video_meta ) {
return 'https://player.vimeo.com/video/' . $video_meta['id'] . '?portrait=0&byline=0&title=0';
}
Check the source to see all of the filters by searching for apply_filters(
How It Works
The Fluid Video Embeds plugin aims to cleanly display YouTube and Vimeo videos while allowing them to be fluid(elastic/felxible) as well. The technique for doing this is not very new (and is outlined in the credits links below), however I've added a bit of "sugar" to the mix. Since Vimeo and YouTube have robust, open APIs, I'm requesting information about each video server side (which is then cached) and used to determine the optimal aspect ratio for the video container.
Credits
fluid-video-embeds
folder and all its contents to the /wp-content/plugins/
directoryI believe that these are the two most popular video platforms (for my current audience) and I coded them first because I am the most familiar with them. I am not opposed to adding video-provider X if their API allows me to.
You can't get the video dimensions (and thus aspect ratio) without doing some sloppy JavaScript (maybe) or making an API call. The only thing that makes this plugin special is that fact that it attempts to remove black bars from your video, thus necessitating API calls. The API requests are cached however, so it should only have a minimal impact.
fve_youtube_iframe_url
, fve_youtube_permalink
, etc.http://
) from the iframe URLs for better https://
support. Thanks to NicholasCook for the fix.<?php echo do_shortcode('[fve]http://www.youtube.com/watch?v=oHg5SJYRHA0[/fve]'); ?>
1.0.3
Fixing an error (Warning/Notice) that was being thrown if the YouTube API did not return an aspect ratio property.
1.0.2
Adding a feed detection function that reverts to the default functionality for oEmbeds if the post is being viewed in a feed.
1.0.1
Added wmode=transparent&
to the YouTube embed URL. This prevents YouTube videos from covering things like lightboxes and other overlapping content.
1.0
Initial release