Version Description
- improvements to the alternative lazyload feature (kudos to Stirius & believableUN and softromano for helping/ testing!)
- lyteCache: if maxresdefault.jpg does not exist, try hqdefault.jpg instead (contribution of R33D3M33R, thanks!)
- some extra filters
Download this release
Release Info
Developer | futtta |
Plugin | WP YouTube Lyte |
Version | 1.7.19 |
Comparing to | |
See all releases |
Code changes from version 1.7.18 to 1.7.19
- lyte/bg-image-layzload.js +1 -1
- lyte/bg-image-layzload.min.js +1 -1
- lyteCache.php +9 -0
- readme.txt +7 -2
- wp-youtube-lyte.php +17 -5
lyte/bg-image-layzload.js
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
* Original source taken from: https://imagekit.io/blog/lazy-loading-images-complete-guide/#lazy-loading-css-background-images
|
3 |
*/
|
4 |
|
5 |
-
|
6 |
var wyl_lazyloadImages;
|
7 |
|
8 |
if ("IntersectionObserver" in window) {
|
2 |
* Original source taken from: https://imagekit.io/blog/lazy-loading-images-complete-guide/#lazy-loading-css-background-images
|
3 |
*/
|
4 |
|
5 |
+
window.addEventListener("load", function() {
|
6 |
var wyl_lazyloadImages;
|
7 |
|
8 |
if ("IntersectionObserver" in window) {
|
lyte/bg-image-layzload.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
|
1 |
+
window.addEventListener("load",function(){var e;if("IntersectionObserver"in window){e=document.querySelectorAll(".wyl-lazy");var n=new IntersectionObserver(function(e,t){e.forEach(function(e){if(e.isIntersecting){var t=e.target;t.classList.remove("wyl-lazy"),n.unobserve(t)}})});e.forEach(function(e){n.observe(e)})}else{var t;function o(){t&&clearTimeout(t),t=setTimeout(function(){var n=window.pageYOffset;e.forEach(function(e){e.offsetTop<window.innerHeight+n&&e.classList.remove("wyl-lazy")}),0==e.length&&(document.removeEventListener("scroll",o),window.removeEventListener("resize",o),window.removeEventListener("orientationChange",o))},20)}e=document.querySelectorAll(".wyl-lazy"),document.addEventListener("scroll",o),window.addEventListener("resize",o),window.addEventListener("orientationChange",o)}});
|
lyteCache.php
CHANGED
@@ -177,6 +177,15 @@ function lyte_get_thumb( $thumbUrl ) {
|
|
177 |
curl_setopt( $curl, CURLOPT_CONNECTTIMEOUT, 5 );
|
178 |
$str = curl_exec( $curl );
|
179 |
$err = curl_error( $curl );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
180 |
curl_close( $curl );
|
181 |
if ( ! $err && $str != '' ) {
|
182 |
return $str;
|
177 |
curl_setopt( $curl, CURLOPT_CONNECTTIMEOUT, 5 );
|
178 |
$str = curl_exec( $curl );
|
179 |
$err = curl_error( $curl );
|
180 |
+
|
181 |
+
// fallback to hqdefault.jpg if maxresdefault.jpg is missing
|
182 |
+
$info = curl_getinfo($curl);
|
183 |
+
if ( 404 === $info['http_code'] && false !== strpos( $thumbUrl, 'maxresdefault.jpg' ) ) {
|
184 |
+
curl_setopt( $curl, CURLOPT_URL, str_replace( 'maxresdefault.jpg', 'hqdefault.jpg', $thumbUrl ) );
|
185 |
+
$str = curl_exec( $curl );
|
186 |
+
$err = curl_error( $curl );
|
187 |
+
}
|
188 |
+
|
189 |
curl_close( $curl );
|
190 |
if ( ! $err && $str != '' ) {
|
191 |
return $str;
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: futtta, optimizingmatters
|
|
3 |
Tags: youtube, video, performance, gdpr, lazy load
|
4 |
Donate link: http://blog.futtta.be/2013/10/21/do-not-donate-to-me/
|
5 |
Requires at least: 4.0
|
6 |
-
Tested up to:
|
7 |
-
Stable tag: 1.7.
|
8 |
|
9 |
High performance YouTube video, playlist and audio-only embeds which don't slow down your blog and offer optimal accessibility.
|
10 |
|
@@ -143,6 +143,11 @@ Just tell me, I like the feedback! Use the [Contact-page on my blog](http://blog
|
|
143 |
|
144 |
== Changelog ==
|
145 |
|
|
|
|
|
|
|
|
|
|
|
146 |
= 1.7.18 =
|
147 |
* small improvements to the integration with the YouTube API, thanks to enchamun and mountbatt for their assistance!
|
148 |
|
3 |
Tags: youtube, video, performance, gdpr, lazy load
|
4 |
Donate link: http://blog.futtta.be/2013/10/21/do-not-donate-to-me/
|
5 |
Requires at least: 4.0
|
6 |
+
Tested up to: 6.0
|
7 |
+
Stable tag: 1.7.19
|
8 |
|
9 |
High performance YouTube video, playlist and audio-only embeds which don't slow down your blog and offer optimal accessibility.
|
10 |
|
143 |
|
144 |
== Changelog ==
|
145 |
|
146 |
+
= 1.7.19 =
|
147 |
+
* improvements to the alternative lazyload feature (kudos to Stirius & believableUN and softromano for helping/ testing!)
|
148 |
+
* lyteCache: if maxresdefault.jpg does not exist, try hqdefault.jpg instead (contribution of R33D3M33R, thanks!)
|
149 |
+
* some extra filters
|
150 |
+
|
151 |
= 1.7.18 =
|
152 |
* small improvements to the integration with the YouTube API, thanks to enchamun and mountbatt for their assistance!
|
153 |
|
wp-youtube-lyte.php
CHANGED
@@ -4,15 +4,17 @@ Plugin Name: WP YouTube Lyte
|
|
4 |
Plugin URI: http://blog.futtta.be/wp-youtube-lyte/
|
5 |
Description: Lite and accessible YouTube audio and video embedding.
|
6 |
Author: Frank Goossens (futtta)
|
7 |
-
Version: 1.7.
|
8 |
Author URI: http://blog.futtta.be/
|
9 |
Text Domain: wp-youtube-lyte
|
10 |
*/
|
11 |
|
|
|
|
|
12 |
if ( ! defined( 'ABSPATH' ) ) exit;
|
13 |
|
14 |
$debug = false;
|
15 |
-
$lyte_version = '1.7.
|
16 |
$lyte_db_version = get_option( 'lyte_version', 'none' );
|
17 |
|
18 |
/** have we updated? */
|
@@ -373,7 +375,12 @@ function lyte_parse( $the_content, $doExcerpt = false ) {
|
|
373 |
|
374 |
/** API: filter hook to parse template before being applied */
|
375 |
$lytetemplate = str_replace( '$', '$', $lytetemplate );
|
376 |
-
|
|
|
|
|
|
|
|
|
|
|
377 |
$the_content = preg_replace( $lytes_regexp, $lytetemplate, $the_content, 1 );
|
378 |
}
|
379 |
|
@@ -460,9 +467,11 @@ function lyte_get_YT_resp( $vid, $playlist=false, $cachekey='', $apiTestKey='',
|
|
460 |
$yt_api_base = 'https://www.googleapis.com/youtube/v3/';
|
461 |
|
462 |
if ( $playlist ) {
|
463 |
-
|
|
|
464 |
} else {
|
465 |
-
|
|
|
466 |
}
|
467 |
}
|
468 |
|
@@ -522,6 +531,9 @@ function lyte_get_YT_resp( $vid, $playlist=false, $cachekey='', $apiTestKey='',
|
|
522 |
}
|
523 |
$_thisLyte['description'] = apply_filters( 'lyte_ytapi_description', $_thisLyte['description'] );
|
524 |
|
|
|
|
|
|
|
525 |
// try to cache the result
|
526 |
if ( ( ( $postID ) || ( $isWidget ) ) && ! empty( $_thisLyte ) && empty( $apiTestKey ) ) {
|
527 |
$_thisLyte['lyte_date_added'] = time();
|
4 |
Plugin URI: http://blog.futtta.be/wp-youtube-lyte/
|
5 |
Description: Lite and accessible YouTube audio and video embedding.
|
6 |
Author: Frank Goossens (futtta)
|
7 |
+
Version: 1.7.19
|
8 |
Author URI: http://blog.futtta.be/
|
9 |
Text Domain: wp-youtube-lyte
|
10 |
*/
|
11 |
|
12 |
+
// fixme: add logic to remove settings/ cache/ ... when removing plugin
|
13 |
+
|
14 |
if ( ! defined( 'ABSPATH' ) ) exit;
|
15 |
|
16 |
$debug = false;
|
17 |
+
$lyte_version = '1.7.19';
|
18 |
$lyte_db_version = get_option( 'lyte_version', 'none' );
|
19 |
|
20 |
/** have we updated? */
|
375 |
|
376 |
/** API: filter hook to parse template before being applied */
|
377 |
$lytetemplate = str_replace( '$', '$', $lytetemplate );
|
378 |
+
|
379 |
+
// make sure *something* is passed as $yt_resp_array to avoid notices in below filter.
|
380 |
+
if ( ! isset( $yt_resp_array ) ) {
|
381 |
+
$yt_resp_array = '';
|
382 |
+
}
|
383 |
+
$lytetemplate = apply_filters( 'lyte_match_postparse_template', $lytetemplate, $templateType, $yt_resp_array );
|
384 |
$the_content = preg_replace( $lytes_regexp, $lytetemplate, $the_content, 1 );
|
385 |
}
|
386 |
|
467 |
$yt_api_base = 'https://www.googleapis.com/youtube/v3/';
|
468 |
|
469 |
if ( $playlist ) {
|
470 |
+
// filter to allow extra data to be requested from YT API, eg. statistics (to get view count).
|
471 |
+
$yt_api_target = apply_filters( 'lyte_filter_ytapi_playlist_params', 'playlists?part=snippet%2C+id&id=' . $vid . '&key=' . $lyte_yt_api_key );
|
472 |
} else {
|
473 |
+
// filter to allow extra data to be requested from YT API, eg. statistics (to get view count).
|
474 |
+
$yt_api_target = apply_filters( 'lyte_filter_ytapi_video_params', 'videos?part=id%2C+snippet%2C+contentDetails&id=' . $vid . '&key=' . $lyte_yt_api_key );
|
475 |
}
|
476 |
}
|
477 |
|
531 |
}
|
532 |
$_thisLyte['description'] = apply_filters( 'lyte_ytapi_description', $_thisLyte['description'] );
|
533 |
|
534 |
+
// add filter to alter what data is cached (adding/ removing).
|
535 |
+
$_thisLyte = apply_filters( 'lyte_filter_ytapi_pre_store_results', $_thisLyte, $yt_resp_array );
|
536 |
+
|
537 |
// try to cache the result
|
538 |
if ( ( ( $postID ) || ( $isWidget ) ) && ! empty( $_thisLyte ) && empty( $apiTestKey ) ) {
|
539 |
$_thisLyte['lyte_date_added'] = time();
|