Youtube Channel Gallery - Version 1.7.3

Version Description

  • Improved management of thumbnails.
  • Corrected thumbnail size selection in playlists.
Download this release

Release Info

Developer javitxu123
Plugin Icon 128x128 Youtube Channel Gallery
Version 1.7.3
Comparing to
See all releases

Code changes from version 1.7.2 to 1.7.3

Files changed (3) hide show
  1. img/play.gif +0 -0
  2. readme.txt +10 -2
  3. youtube-channel-gallery.php +32 -17
img/play.gif DELETED
Binary file
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://poselab.com/
4
  Tags: widget, gallery, youtube, channel, user, sidebar, video, youtube playlist, html5, iframe, Youtube channel, youtube videos
5
  Requires at least: 2.8
6
  Tested up to: 3.4.1
7
- Stable tag: 1.7.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -100,7 +100,11 @@ The “widgets” admin page is found in the administrator part (wp-admin) of yo
100
 
101
  = How do I find the YouTube user id? =
102
 
103
- The username who uploaded a video to Youtube is located below each video, where says something like in this example, "Published on June 25, 2012 by DisneyShorts", where DisneyShorts is the username.
 
 
 
 
104
 
105
 
106
  == Screenshots ==
@@ -114,6 +118,10 @@ The username who uploaded a video to Youtube is located below each video, where
114
 
115
  == Changelog ==
116
 
 
 
 
 
117
  = 1.7.2 =
118
  * Added playlist feed support.
119
  * Added control to select video quality.
4
  Tags: widget, gallery, youtube, channel, user, sidebar, video, youtube playlist, html5, iframe, Youtube channel, youtube videos
5
  Requires at least: 2.8
6
  Tested up to: 3.4.1
7
+ Stable tag: 1.7.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
100
 
101
  = How do I find the YouTube user id? =
102
 
103
+ The username who uploaded a video to Youtube is located below each video, where says something like in this example, "Published on June 25, 2012 by DisneyShorts", where DisneyShorts is the username. Click on the user name and you will find the user id in the url of that page: https://www.youtube.com/user/DisneyShorts. DisneyShorts is the id of that user.
104
+
105
+ = How do I find a YouTube playlist id? =
106
+
107
+ If you go to a playlist you will get the following url format: https://www.youtube.com/playlist?list=PL33942589618ABDE3. The playlist id is what you have after list=. In this example, the playlist id is PL33942589618ABDE3.
108
 
109
 
110
  == Screenshots ==
118
 
119
  == Changelog ==
120
 
121
+ = 1.7.3 =
122
+ * Improved management of thumbnails.
123
+ * Corrected thumbnail size selection in playlists.
124
+
125
  = 1.7.2 =
126
  * Added playlist feed support.
127
  * Added control to select video quality.
youtube-channel-gallery.php CHANGED
@@ -5,7 +5,7 @@
5
  Description: Show a youtube video and a gallery of thumbnails for a youtube channel.
6
  Author: Javier Gómez Pose
7
  Author URI: http://www.poselab.com/
8
- Version: 1.7.2
9
  License: GPL2
10
 
11
  Copyright 2010 Javier Gómez Pose (email : javierpose@gmail.com)
@@ -577,32 +577,39 @@
577
  if (!empty($items)) {
578
  $i = 0;
579
  $column = 0;
 
580
  foreach ( $items as $item ) {
581
  $url = $item->get_permalink();
582
  $youtubeid = $this->youtubeid($url);
583
  $title = $item->get_title();
584
  $description = $item->get_description();
585
 
 
586
  if ($enclosure = $item->get_enclosure()){
 
 
 
 
 
587
 
588
- //extract thumbnail
589
- //-----------------
 
590
 
591
- //thumbnail index in xml
592
- $big = 0;
593
- $small = 1;
594
- $size = $small;
595
- if($ytchag_thumb_width > '120'){
596
- $size = $big;
597
  }
 
 
598
 
599
- $allThumbs = $enclosure->get_thumbnails();
600
- foreach ($allThumbs as $index => $allThumb) {
601
- if ($index == $size) {
602
- $thumb = $allThumbs[$index];
603
- }
604
- }
605
- }
606
 
607
 
608
  //title and description content
@@ -652,7 +659,6 @@
652
  //Show me the player: iframe player
653
  if($i == 0) {
654
  //count the plugin occurrences on page
655
- STATIC $plugincount = 0;
656
  $plugincount++;
657
 
658
  $content = '<iframe id="ytcplayer' . $plugincount . '" class="ytcplayer" allowfullscreen width="' . $ytchag_video_width . '" height="' . $ytchag_video_heigh . '" src="http://www.youtube.com/embed/' . $youtubeid . '?version=3' . $ytchag_theme . $ytchag_color . $ytchag_autoplay . $ytchag_rel . $ytchag_showinfo .'&enablejsapi=1" frameborder="0"></iframe>';
@@ -734,6 +740,15 @@
734
  }//youtubeid
735
 
736
 
 
 
 
 
 
 
 
 
 
737
  // load css or js
738
  private function register_scripts_and_styles() {
739
  wp_enqueue_script('jquery');
5
  Description: Show a youtube video and a gallery of thumbnails for a youtube channel.
6
  Author: Javier Gómez Pose
7
  Author URI: http://www.poselab.com/
8
+ Version: 1.7.3
9
  License: GPL2
10
 
11
  Copyright 2010 Javier Gómez Pose (email : javierpose@gmail.com)
577
  if (!empty($items)) {
578
  $i = 0;
579
  $column = 0;
580
+ STATIC $plugincount = 0;
581
  foreach ( $items as $item ) {
582
  $url = $item->get_permalink();
583
  $youtubeid = $this->youtubeid($url);
584
  $title = $item->get_title();
585
  $description = $item->get_description();
586
 
587
+ //default url thumbnail
588
  if ($enclosure = $item->get_enclosure()){
589
+ $thumb = $enclosure->get_thumbnail();
590
+ }
591
+
592
+ //to appropriate thumbnail
593
+ if($plugincount == 0){
594
 
595
+ //media:thumbnail tag
596
+ $media_group = $item->get_item_tags('http://search.yahoo.com/mrss/', 'group');
597
+ $media_content = $media_group[0]['child']['http://search.yahoo.com/mrss/']['thumbnail'];
598
 
599
+ //Check the thumbnail width
600
+ $thumbW = array();
601
+ foreach ($media_content as $index => $media_contentw) {
602
+ $thumbW[$index] = $media_content[$index]['attribs']['']['width'];
 
 
603
  }
604
+ //appropriate thumbnail width
605
+ $thumbcorrectW = $this->closest($thumbW, $ytchag_thumb_width);
606
 
607
+ //index in array of thumbnail width
608
+ $thumbcorrectWIndex = array_search($thumbcorrectW, $thumbW);
609
+
610
+ //appropriate url thumbnail
611
+ $thumb = $media_content[$thumbcorrectWIndex]['attribs']['']['url'];
612
+ }
 
613
 
614
 
615
  //title and description content
659
  //Show me the player: iframe player
660
  if($i == 0) {
661
  //count the plugin occurrences on page
 
662
  $plugincount++;
663
 
664
  $content = '<iframe id="ytcplayer' . $plugincount . '" class="ytcplayer" allowfullscreen width="' . $ytchag_video_width . '" height="' . $ytchag_video_heigh . '" src="http://www.youtube.com/embed/' . $youtubeid . '?version=3' . $ytchag_theme . $ytchag_color . $ytchag_autoplay . $ytchag_rel . $ytchag_showinfo .'&enablejsapi=1" frameborder="0"></iframe>';
740
  }//youtubeid
741
 
742
 
743
+ private function closest($array, $number) {
744
+ sort($array);
745
+ foreach ($array as $a) {
746
+ if ($a >= $number) return $a;
747
+ }
748
+ return end($array); // or return NULL;
749
+
750
+ }
751
+
752
  // load css or js
753
  private function register_scripts_and_styles() {
754
  wp_enqueue_script('jquery');