=== WP YouTube Lyte === Contributors: futtta, optimizingmatters Tags: youtube, video, performance, gdpr, lazy load Donate link: http://blog.futtta.be/2013/10/21/do-not-donate-to-me/ License: GPLv3 License URI: [https://www.gnu.org/licenses/gpl-3.0.html](https://www.gnu.org/licenses/gpl-3.0.html) Requires at least: 4.0 Tested up to: 6.8 Stable tag: 1.7.27 High performance YouTube video, playlist and audio-only embeds which don't slow down your blog and offer optimal accessibility. == Description == WP YouTube Lyte allows you to "lazy load" your video's, by inserting responsive "Lite YouTube Embeds". These look and feel like normal embedded YouTube, but only call the "fat" YouTube-player when clicked on, thereby [reducing download size & rendering time substantially](http://blog.futtta.be/2012/04/03/speed-matters-re-evaluating-wp-youtube-lytes-performance/) when embedding YouTube occasionally and improving page performance dramatically when you've got multiple YouTube video's on one and the same page. The plugin can be configured to cache YouTube thumbnails locally, improving both performance and privacy. As such LYTE embedded YouTube videos do not require requests to the YouTube servers, probably (I am not a lawyer) allowing for better GDPR-compliance. The plugin picks up on normal YouTube links, taking over from WordPress core's oEmbed. Alternatively you can add a YouTube-link for a video or [an entire playlist](http://blog.futtta.be/2011/10/11/wp-youtube-lyte-support-for-playlists-almost-included/) with "httpv" instead of "http(s)" or add a Lyte widget to your sidebar and WP YouTube Lyte replaces that link with the correct performance-optimized code. Some examples: * httpv://www.youtube.com/watch?v=_SQkWbRublY (normal video embed) * httpv://youtu.be/_SQkWbRublY (video embed with youtube-shortlink) * httpa://www.youtube.com/watch?v=_SQkWbRublY (audio only embed) * httpv://www.youtube.com/playlist?list=PLA486E741B25F8E00 (playlist embed) * httpv://www.youtube.com/watch?v=_SQkWbRublY#stepSize=-1 (video player, one size smaller than what's configured as default) * httpv://www.youtube.com/watch?v=_SQkWbRublY?start=20&showinfo=0 (video player, start playing at 20 seconds and don't show title) Or using shortcodes: `[lyte id='_SQkWbRublY' /]` `[lyte id='_SQkWbRublY' audio='true' /]` `[lyte id='A486E741B25F8E00' playlist='true' /]` WP YouTube Lyte has been written with optimal performance as primary goal, but has been tested for maximum browser-compatibility (iPad included) while keeping an eye on accessibility. Starting with version 1.2.0 lyte embeds are fully responsive and can automatically embed [videoObject microdata](http://support.google.com/webmasters/bin/answer.py?hl=en&answer=2413309) as well. The plugin is fully multi-language, with support for Catalan, Dutch, English, French, German, Hebrew, Romanian, Spanish and Slovene. Feedback is welcome; see [info in the faq](http://wordpress.org/extend/plugins/wp-youtube-lyte/faq/) for bug reports/ feature requests and feel free to [rate and/or report on compatibility on wordpress.org](http://wordpress.org/extend/plugins/wp-youtube-lyte/). == Installation == Just install form your Wordpress "Plugins|Add New" screen and all will be well. Manual installation is very straightforward as well: 1. Upload the zip-file and unzip it in the `/wp-content/plugins/` directory 2. Activate the plugin through the 'Plugins' menu in WordPress 3. Place a link to a YouTube clip like this; httpv://www.youtube.com/watch?v=_SQkWbRublY == Frequently Asked Questions == = Why does WP YouTube Lyte need to access the YouTube API? What is an API anyway? = An API is a way to have two pieces of software talk to each other to exchange information. In this case WP YouTube Lyte contacts YouTube to ask it for the thumbnail, the title and the description of the video you added. The thumbnail and title are visible on the webpage (in the Lyte player) while the description is in the HTML as microdata for search engines optimization reasons (see below). = OK, now how can get that API key? = 1. Go to [Google Developer Console](https://console.developers.google.com/projectselector/apis/library) and log in with your Google account. 2. Click on 'Create Project' and: * Fill in a Project Name * Fill in a Project ID * Click on 'Create' 3. On the next page (or when there is no next page, click on your Project's name): * Scroll down to YouTube Data API v3 and click on it * Click on 'ENABLE' at the top to enable the API * Optionally disable other API's 4. In the sidebar on the left: * Click on 'Credentials' * Click on 'Create Credential' at the top. * Click on 'API key' * Set as little restrictions as possible, most problems with getting this working are caused by these settings. * Click on 'Create' 5. Copy your API key to WP YouTube Lyte settings page. = I'm getting "technical errors" when validating my YouTube API key = In certain cases when adding restrictions the API key when tested might give technical warnings even if things are working correctly, make sure to check if new video’s are having the title displayed to confirm all is well. = Will WP YouTube Lyte work if I don't provide an API key? = Yes, with some exceptions; WP YouTube Lyte will continue to work, rendering Lyte players, but without the title and microdata (description, time, ...) and without thumbnails for playlists. = I don't want an API key, how can I get rid of the "API key"-notice? = Just enter "none" (without the quotes) in the API key field and Lyte will stop nagging you. = Does WP YouTube Lyte protect my visitor's privacy? = As opposed to some of the [most important](http://blog.futtta.be/2010/12/15/wordpress-com-stats-trojan-horse-for-quantcast-tracking/) [plugins](http://blog.futtta.be/2010/01/22/add-to-any-removed-from-here/) there is no 3rd party tracking code in WP YouTube Lyte, but YouTube off course does see visitor requests coming in for the thumbnails unless the option to cache thumbnails locally is enabled. If thumbnails are cached locally, no request will be sent to YouTube by your visitor's browser until/ unless the video is played. = I use a page builder and LYTE does not seem active on the YouTube video's I add there? = LYTE by default uses WordPress' "the_content"-filter. Page builders don't apply that filter to their content and thus LYTE does not get triggered on those. As a workaround you can either add the LYTE widget or add the LYTE video using the shortcode in your page-builder Text-block, this works in most page-builders. = Can I use WP YouTube Lyte for a custom field? = Just pass the httpv url of such a field to lyte_preparse like this: `if(function_exists('lyte_preparse')) { echo lyte_preparse($video); }` and you're good to go! = Does WP YouTube Lyte work with Infinite Scroll? = Starting from version 1.1.0 it does; in [Infinite Scroll](http://wordpress.org/extend/plugins/infinite-scroll/)'s configuration you just have to add "ly.te()" in the "Javascript to be called after the next posts are fetched"-box. = How does WP YouTube Lyte support microdata? = * There is a [specific microdata scheme for "videoObject"](http://support.google.com/webmasters/bin/answer.py?hl=en&answer=2413309) which WP YouTube Lyte can add to your page, which Google can use to display the video thumbnail next to the search-result * This is optional and can be disabled in the options page * The videoobject microdata is NOT added for audio-only embeds, playlists or widgets * Google will not always display the thumbnail, this presumably depends of the relevance of the video to the rest of the page. = How does captions-support get added to the microdata? = In January 2014 [Benetech](http://benetech.org/), a U.S. nonprofit that develops and uses technology to create positive social change, offered a patch that adds the [accessibilityFeature property](http://schema.org/accessibilityFeature) to the microdata for videos that have captions. If you have microdata enabled, WP YouTube Lyte will automatically try to check (in a seperate, asynchronous call via a proxy-webservice, as YouTube only offers captions in their API v3 which requires authentication) if captions are available and if so, adds the accessibilityFeature property with value captions to the microdata. This can be disabled by either disabling microdata or, if you want microdata but not the accessibilityFeature-property by using the "lyte_docaptions"-filter to set captions to false (example-code is in lyte_helper.php_example). = Responsive LYTE embeds = * The video width in posts and pages will adapt to the width of the container (the div) in which your blogposts/ pages are shown. This means that if your theme is responsive, WP YouTube Lyte will follow. * Widgets are not responsive. * if the content div width gets to around 200 pixels, the LYTE UI will become garbled (YouTube requires the minimum embed width to be 200px as well). = Can I use WP YouTube Lyte on normal YouTube links or iframes? = Yes, starting with version 1.5.0 normal YouTube links are automatically transferred in Lyte embeds as well. You will automagically also get a (non-Lyte) preview of the video in your visual post edit screen. Starting from LYTE 1.7.5 YouTube iframes can be automatically converted as well. = What can I do with the API? = A whole lot; there are filters to pre-parse the_content, to change settings, to change the CSS, to change the HTML of the LYTE-div, ... There are examples for all filters (and one action) in lyte_helper.php_example = Problem with All In One Seo Pack = All in One SEO Pack be default generates a description which still has httpv-links in it. To remove those, you'll have to use (example code in) lyte_helper.php (see above) and add lyte_filter_aioseop_description to the aioseop-filter in there. = When I click on a LYTE video, a link to YouTube opens, what's up with that? = You probably added a link around the httpv-url. No link is needed, just the httpv-url. = My video's seem to load slower on mobile devices? = By default (unless "cache thumbnail locally" is active) WP YouTube Lyte will indeed load slower normal YouTube video's instead of Lyte ones, as Lyte video's require would require two clicks from the user to play a video (once to load the YouTube video and once to start it) because there is no autoplay-support on mobile. If you want to, you can force WP YouTube Lyte to make video's Lyte on mobile with this code (add it in your child theme's functions.php, in a seperate helper plugin or using the [code snippets plugin](https://wordpress.org/plugins/code-snippets/); `add_filter( 'lyte_do_mobile', '__return_true' );` = lyteCache.php is using a lot of resources = lyteCache.php is a standalone file (it does not rely on WordPress) that is used when local thumbnail caching is active, which means requests for those thumbnails are handled by PHP. In WP YouTube Lyte 1.7.14 logic was added to prevent lyteCache.php doing thumbnail caching when being called directy without "local thumbnail caching" being active. Moreover if you want to ensure the thumbnails can only be used on your own site (and not hotlinked) you can use this code snippet: `add_filter( 'lyte_filter_local_thumb_doublecheck', '__return_true' );` This will have WP YouTube Lyte set (in JavaScript in the HTML) and check (in the request for the thumbnail) a cookie. If the cookie is not set, the image request will be redirected to the YouTube origin URL. = Any other issues should I know about? = * Having the same YouTube-video on one page can cause WP YouTube Lyte to malfunction (as the YouTube id is used as the div's id in the DOM, and DOM id's are supposed to be unique) = I found a bug/ I would like a feature to be added! = Just tell me, I like the feedback! Use the [Contact-page on my blog](http://blog.futtta.be/contact/), [leave a comment in a post about wp-youtube-lyte](http://blog.futtta.be/tag/wp-youtube-lyte/) or [create a new topic on the wordpress.org forum](http://wordpress.org/tags/wp-youtube-lyte?forum_id=10#postform). = How you can help = * Tell me about bugs you think you've found and if you can't find any, [confirm it works with your version of WP on wordpress.org](http://wordpress.org/extend/plugins/wp-youtube-lyte/) * Ask me for a feature you would like to see added * [Rate my plugin on wordpress.org](http://wordpress.org/extend/plugins/wp-youtube-lyte/) == Changelog == = 1.7.27 = * fix for the _load_textdomain_just_in_time notice * fix for youtube URL in text getting replaced if the same URL is already replaced correctly, kudo's to Nic Jansma! = 1.7.26 = * fix the figcaption regression = 1.7.25 = * fix for regression that saw youtu.be links in WordPress blocks break. = 1.7.24 = * Compatibility with bedrock-autoloader (thanks to Gerwin Jansen) * Improve alignment for Gutenberg YouTube/ video block (kudo's to Benjamin Pick) * removed type="text/javascript" attribute from