WP YouTube Lyte - Version 1.7.4

Version Description

  • improvement: make sure locally cached thumbnails are served with good HTTP response headers (allowing HTTP 304 responses and allowing images to be cached in browser).
  • improvemnet: bigger widget sizes for use in pagebuilders.
Download this release

Release Info

Developer futtta
Plugin Icon 128x128 WP YouTube Lyte
Version 1.7.4
Comparing to
See all releases

Code changes from version 1.7.3 to 1.7.4

Files changed (5) hide show
  1. lyteThumbs.php +19 -2
  2. player_sizes.inc.php +11 -0
  3. readme.txt +6 -2
  4. widget.php +3 -3
  5. wp-youtube-lyte.php +1 -1
lyteThumbs.php CHANGED
@@ -102,8 +102,25 @@ if ( $thumbContents != "") {
102
  if ( $lyte_thumb_error !== "" && $lyte_thumb_report_err ) {
103
  header('X-lyte-error: '.$lyte_thumb_error);
104
  }
105
- header('Content-type:image/jpeg');
106
- echo $thumbContents;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
  } else {
108
  $lyte_thumb_error .= "no thumbContent/ ";
109
  lyte_thumb_fallback();
102
  if ( $lyte_thumb_error !== "" && $lyte_thumb_report_err ) {
103
  header('X-lyte-error: '.$lyte_thumb_error);
104
  }
105
+
106
+ $modTime=filemtime($localThumb);
107
+
108
+ date_default_timezone_set("UTC");
109
+ $modTimeMatch = (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) === $modTime);
110
+
111
+ if ( $modTimeMatch ) {
112
+ header('HTTP/1.1 304 Not Modified');
113
+ header('Connection: close');
114
+ } else {
115
+ // send all sorts of headers
116
+ $expireTime=60*60*24*7; // 1w
117
+ header('Content-Length: '.strlen($thumbContents));
118
+ header('Cache-Control: max-age='.$expireTime.', public, immutable');
119
+ header('Expires: '.gmdate('D, d M Y H:i:s', time() + $expireTime).' GMT');
120
+ header('Last-Modified: '.gmdate('D, d M Y H:i:s', $modTime).' GMT');
121
+ header('Content-type:image/jpeg');
122
+ echo $thumbContents;
123
+ }
124
  } else {
125
  $lyte_thumb_error .= "no thumbContent/ ";
126
  lyte_thumb_fallback();
player_sizes.inc.php CHANGED
@@ -85,4 +85,15 @@ $wSize[6]['depr']=false;
85
  $wSize[7]['h']=300;
86
  $wSize[7]['w']=400;
87
  $wSize[7]['depr']=false;
 
 
 
 
 
 
 
 
 
 
 
88
  ?>
85
  $wSize[7]['h']=300;
86
  $wSize[7]['w']=400;
87
  $wSize[7]['depr']=false;
88
+
89
+ // bigger widgets, for use in pagebuilders rather then sidebars
90
+ $wSize[8]['h']=400;
91
+ $wSize[8]['w']=711;
92
+ $wSize[8]['depr']=false;
93
+ $wSize[9]['h']=500;
94
+ $wSize[9]['w']=889;
95
+ $wSize[9]['depr']=false;
96
+ $wSize[10]['h']=600;
97
+ $wSize[10]['w']=1066;
98
+ $wSize[10]['depr']=false;
99
  ?>
readme.txt CHANGED
@@ -4,7 +4,7 @@ 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: 4.9
7
- Stable tag: 1.7.3
8
 
9
  High performance YouTube video, playlist and audio-only embeds which don't slow down your blog and offer optimal accessibility.
10
 
@@ -77,7 +77,7 @@ Just enter "none" (without the quotes) in the API key field and Lyte will stop n
77
  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.
78
 
79
  = I use a page builder and LYTE does not seem active on the YouTube video's I add there? =
80
- 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 add the LYTE video using the shortcode in your page-builder Text-block, this works in most page-builders.
81
 
82
  = Can I use WP YouTube Lyte for a custom field? =
83
  Just pass the httpv url of such a field to lyte_preparse like this:
@@ -137,6 +137,10 @@ Just tell me, I like the feedback! Use the [Contact-page on my blog](http://blog
137
 
138
  == Changelog ==
139
 
 
 
 
 
140
  = 1.7.3 =
141
  * switched YouTube to youtube-nocookie.com.
142
  * added span around description to ensure it can be styled separately.
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: 4.9
7
+ Stable tag: 1.7.4
8
 
9
  High performance YouTube video, playlist and audio-only embeds which don't slow down your blog and offer optimal accessibility.
10
 
77
  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.
78
 
79
  = I use a page builder and LYTE does not seem active on the YouTube video's I add there? =
80
+ 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 video using the shortcode in your page-builder Text-block or use the LYTE widget (selecting one of the bigger widget sizes), this works in most page-builders.
81
 
82
  = Can I use WP YouTube Lyte for a custom field? =
83
  Just pass the httpv url of such a field to lyte_preparse like this:
137
 
138
  == Changelog ==
139
 
140
+ = 1.7.4 =
141
+ * improvement: make sure locally cached thumbnails are served with good HTTP response headers (allowing HTTP 304 responses and allowing images to be cached in browser).
142
+ * improvemnet: bigger widget sizes for use in pagebuilders.
143
+
144
  = 1.7.3 =
145
  * switched YouTube to youtube-nocookie.com.
146
  * added span around description to ensure it can be styled separately.
widget.php CHANGED
@@ -31,14 +31,14 @@ class WYLWidget extends WP_Widget {
31
  if (strpos($WYLurl,'youtu.be')) {
32
  $WYLid=substr(parse_url($WYLurl,PHP_URL_PATH),1,11);
33
  $PLClass="";
34
- $WYLthumb="https://img.youtube.com/vi/".$WYLid."/mqdefault.jpg";
35
  } else {
36
  if (isset($WYLarr['v'])) {
37
  $WYLid=$WYLarr['v'];
38
  $PLClass="";
39
- $WYLthumb="https://img.youtube.com/vi/".$WYLid."/mqdefault.jpg";
40
  } else if (isset($WYLarr['list'])) {
41
- $WYLid=$WYLarr['list'];
42
  $yt_resp=lyte_get_YT_resp($WYLid,true,"","",true);
43
  $WYLthumb=$yt_resp["thumbUrl"];
44
  $PLClass=" playlist";
31
  if (strpos($WYLurl,'youtu.be')) {
32
  $WYLid=substr(parse_url($WYLurl,PHP_URL_PATH),1,11);
33
  $PLClass="";
34
+ $WYLthumb="https://img.youtube.com/vi/".$WYLid."/hqdefault.jpg";
35
  } else {
36
  if (isset($WYLarr['v'])) {
37
  $WYLid=$WYLarr['v'];
38
  $PLClass="";
39
+ $WYLthumb="https://img.youtube.com/vi/".$WYLid."/hqdefault.jpg";
40
  } else if (isset($WYLarr['list'])) {
41
+ $WYLid=$WYLarr['list'];
42
  $yt_resp=lyte_get_YT_resp($WYLid,true,"","",true);
43
  $WYLthumb=$yt_resp["thumbUrl"];
44
  $PLClass=" playlist";
wp-youtube-lyte.php CHANGED
@@ -4,7 +4,7 @@ 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.3
8
  Author URI: http://blog.futtta.be/
9
  Text Domain: wp-youtube-lyte
10
  Domain Path: /languages
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.4
8
  Author URI: http://blog.futtta.be/
9
  Text Domain: wp-youtube-lyte
10
  Domain Path: /languages