Slideshow - Version 2.2.7

Version Description

  • Fixed: Slideshow control buttons were placed behind the slideshow.
  • Fixed: Image slides doubly inserted after having clicked on 'Load more results'
  • Included width and height attributes on all image elements.
Download this release

Release Info

Developer stefanboonstra
Plugin Icon 128x128 Slideshow
Version 2.2.7
Comparing to
See all releases

Code changes from version 2.2.6 to 2.2.7

classes/SlideshowPluginSlideInserter.php CHANGED
@@ -85,26 +85,39 @@ class SlideshowPluginSlideInserter {
85
  if(isset($_POST['offset']) && is_numeric($_POST['offset']))
86
  $offset = $_POST['offset'];
87
 
 
 
 
 
88
  // Get attachments with a title alike the search string, needs to be filtered
89
  add_filter('posts_where', array(__CLASS__, 'printSearchResultsWhereFilter'));
90
- $attachments = get_posts(array(
91
- 'numberposts' => $numberPosts + 1,
 
92
  'offset' => $offset,
93
- 'orderby' => 'post_date',
 
94
  'order' => 'DESC',
95
- 'post_type' => 'attachment',
96
- 'suppress_filters' => false
97
  ));
 
98
  remove_filter('posts_where', array(__CLASS__, 'printSearchResultsWhereFilter'));
99
 
100
  // Look for images by their file's name when not enough matching results were found
101
  if(count($attachments) < $numberPosts){
102
  $searchString = $wpdb->escape($_POST['search']);
103
 
104
- $query = new WP_Query(array(
 
 
 
 
 
 
105
  'post_type' => 'attachment',
106
  'post_status' => 'inherit',
107
  'posts_per_page' => $numberPosts - count($attachments),
 
108
  'meta_query' => array(
109
  array(
110
  'key' => '_wp_attached_file',
@@ -114,19 +127,23 @@ class SlideshowPluginSlideInserter {
114
  )
115
  ));
116
 
117
- $queryAttachments = $query->get_posts();
118
- if(is_array($queryAttachments) && count($queryAttachments) > 0){
119
-
120
- for($i = 0; $i < count($queryAttachments); $i++){
121
-
122
- $inAttachmentsArray = false;
123
- foreach($attachments as $attachmentValue)
124
- if($attachmentValue->ID == $queryAttachments[$i]->ID)
125
- $inAttachmentsArray = true;
126
-
127
- if(!$inAttachmentsArray)
128
- $attachments[] = $queryAttachments[$i];
129
- }
 
 
 
 
130
  }
131
  }
132
 
@@ -139,6 +156,14 @@ class SlideshowPluginSlideInserter {
139
 
140
  // Print results to the screen
141
  if(count($attachments) > 0){
 
 
 
 
 
 
 
 
142
  foreach($attachments as $attachment){
143
  $image = wp_get_attachment_image_src($attachment->ID);
144
  if(!is_array($image) || !$image){
@@ -150,7 +175,7 @@ class SlideshowPluginSlideInserter {
150
  $imageSrc = $image[0];
151
  }
152
  if(!$imageSrc || empty($imageSrc)) $imageSrc = SlideshowPluginMain::getPluginUrl() . '/images/SlideshowPluginPostType/no-img.png';
153
- echo '<tr valign="top">
154
  <td class="image">
155
  <img width="60" height="60" src="' . $imageSrc . '" class="attachment" alt="' . $attachment->post_title . '" title="' . $attachment->post_title . '">
156
  </td>
@@ -161,7 +186,6 @@ class SlideshowPluginSlideInserter {
161
  <td class="insert-button">
162
  <input
163
  type="button"
164
- id="' . $attachment->ID . '"
165
  class="insert-attachment button-secondary"
166
  value="' . __('Insert', 'slideshow-plugin') . '"
167
  />
85
  if(isset($_POST['offset']) && is_numeric($_POST['offset']))
86
  $offset = $_POST['offset'];
87
 
88
+ $attachmentIDs = array();
89
+ if(isset($_POST['attachmentIDs']))
90
+ $attachmentIDs = array_filter($_POST['attachmentIDs'], 'ctype_digit');
91
+
92
  // Get attachments with a title alike the search string, needs to be filtered
93
  add_filter('posts_where', array(__CLASS__, 'printSearchResultsWhereFilter'));
94
+ $query = new WP_Query(array(
95
+ 'post_type' => 'attachment',
96
+ 'post_status' => 'inherit',
97
  'offset' => $offset,
98
+ 'posts_per_page' => $numberPosts + 1,
99
+ 'orderby' => 'date',
100
  'order' => 'DESC',
101
+ 'post__not_in' => $attachmentIDs
 
102
  ));
103
+ $attachments = $query->get_posts();
104
  remove_filter('posts_where', array(__CLASS__, 'printSearchResultsWhereFilter'));
105
 
106
  // Look for images by their file's name when not enough matching results were found
107
  if(count($attachments) < $numberPosts){
108
  $searchString = $wpdb->escape($_POST['search']);
109
 
110
+ // Add results found with the previous query to the $attachmentIDs array to exclude them as well
111
+ foreach($attachments as $attachment){
112
+ $attachmentIDs[] = $attachment->ID;
113
+ }
114
+
115
+ // Search by file name
116
+ $fileNameQuery = new WP_Query(array(
117
  'post_type' => 'attachment',
118
  'post_status' => 'inherit',
119
  'posts_per_page' => $numberPosts - count($attachments),
120
+ 'post__not_in' => $attachmentIDs,
121
  'meta_query' => array(
122
  array(
123
  'key' => '_wp_attached_file',
127
  )
128
  ));
129
 
130
+ // Put found results in attachments array
131
+ $fileNameQueryAttachments = $fileNameQuery->get_posts();
132
+ if(is_array($fileNameQueryAttachments) && count($fileNameQueryAttachments) > 0){
133
+
134
+ foreach($fileNameQueryAttachments as $fileNameQueryAttachment)
135
+ $attachments[] = $fileNameQueryAttachment;
136
+
137
+ // for($i = 0; $i < count($fileNameQueryAttachments); $i++){
138
+ //
139
+ // $inAttachmentsArray = false;
140
+ // foreach($attachments as $attachmentValue)
141
+ // if($attachmentValue->ID == $fileNameQueryAttachments[$i]->ID)
142
+ // $inAttachmentsArray = true;
143
+ //
144
+ // if(!$inAttachmentsArray)
145
+ // $attachments[] = $fileNameQueryAttachments[$i];
146
+ // }
147
  }
148
  }
149
 
156
 
157
  // Print results to the screen
158
  if(count($attachments) > 0){
159
+
160
+ if($offset > 0)
161
+ echo '<tr valign="top">
162
+ <td colspan="3" style="text-align: center;">
163
+ <b>' . count($attachments) . ' ' . __('More results loaded', 'slideshow-plugin') . '<b>
164
+ </td>
165
+ </tr>';
166
+
167
  foreach($attachments as $attachment){
168
  $image = wp_get_attachment_image_src($attachment->ID);
169
  if(!is_array($image) || !$image){
175
  $imageSrc = $image[0];
176
  }
177
  if(!$imageSrc || empty($imageSrc)) $imageSrc = SlideshowPluginMain::getPluginUrl() . '/images/SlideshowPluginPostType/no-img.png';
178
+ echo '<tr valign="top" data-attachment-Id="' . $attachment->ID . '" class="result-table-row">
179
  <td class="image">
180
  <img width="60" height="60" src="' . $imageSrc . '" class="attachment" alt="' . $attachment->post_title . '" title="' . $attachment->post_title . '">
181
  </td>
186
  <td class="insert-button">
187
  <input
188
  type="button"
 
189
  class="insert-attachment button-secondary"
190
  value="' . __('Insert', 'slideshow-plugin') . '"
191
  />
js/SlideshowPlugin/slideshow.min.js CHANGED
@@ -1 +1 @@
1
- jQuery.fn.slideshow_jquery_image_gallery_script=function(){var $=jQuery;var $container=$(this),$content=$container.find('.slideshow_content'),$views=$container.find('.slideshow_view'),$slides=$container.find('.slideshow_slide'),$controlPanel=$container.find('.slideshow_controlPanel'),$togglePlayButton=$controlPanel.find('.slideshow_togglePlay'),$nextButton=$container.find('.slideshow_next'),$previousButton=$container.find('.slideshow_previous'),$pagination=$container.find('.slideshow_pagination');var $ID=getID();var $settings=window['SlideshowPluginSettings_'+$ID];$.each($settings,function(setting,value){if(value=='true')$settings[setting]=true;else if(value=='false')$settings[setting]=false});var $parentElement=$container.parent(),$viewData=[],$navigationActive=true,$currentViewId=getNextViewId(),$currentWidth=0,$visibleViews=[$currentViewId],$videoPlayers=[],$interval='',$mouseEnterTimer='',$invisibilityTimer='';init();function init(){recalculate(false);$.each($views,function(viewId,view){recalculateView(view);if(viewId!=$visibleViews[0])$(view).css('top',$container.outerHeight(true));$viewData[viewId]=[];$.each($(view).find('.slideshow_slide'),function(slideId,slide){$viewData[viewId][slideId]={'imageDimension':''}})});$content.show();$(window).load(function(){recalculateVisibleViews()});if($settings['enableResponsiveness']){$(window).resize(function(){recalculate()})}if(parseFloat($settings['intervalSpeed'])<parseFloat($settings['slideSpeed'])+0.1)$settings['intervalSpeed']=parseFloat($settings['slideSpeed'])+0.1;activateDescriptions();activateControlPanel();activateNavigationButtons();activatePagination();activatePauseOnHover();start()}function start(){if(!$settings['play'])return;$interval=setInterval(function(){animateTo(getNextViewId(),1)},$settings['intervalSpeed']*1000)}function stop(){clearInterval($interval);$interval=false}function animateTo(viewId,direction){if(videoIsPlaying()||viewId<0||viewId>=$views.length||viewId==$currentViewId)return;$navigationActive=false;if(direction==0||direction==undefined){if(viewId<$currentViewId)direction=-1;else direction=1}$visibleViews=[$currentViewId,viewId];var animation=$settings['animation'];var animations=['slide','slideRight','slideUp','slideDown','fade','directFade'];if(animation=='random')animation=animations[Math.floor(Math.random()*animations.length)];var animationOpposites={'slide':'slideRight','slideRight':'slide','slideUp':'slideDown','slideDown':'slideUp','fade':'fade','directFade':'directFade'};if(direction<0)animation=animationOpposites[animation];var currentView=$($views[$currentViewId]);var nextView=$($views[viewId]);currentView.stop(true,true);nextView.stop(true,true);recalculateVisibleViews();$currentViewId=viewId;$container.trigger('onSlideshowAnimate');switch(animation){case'slide':recalculateVisibleViews();nextView.css({top:0,left:$content.width()});currentView.animate({left:-currentView.outerWidth(true)},$settings['slideSpeed']*1000);nextView.animate({left:0},$settings['slideSpeed']*1000);setTimeout(function(){currentView.stop(true,true).css('top',$container.outerHeight(true))},$settings['slideSpeed']*1000);break;case'slideRight':nextView.css({top:0,left:-$content.width()});currentView.animate({left:currentView.outerWidth(true)},$settings['slideSpeed']*1000);nextView.animate({left:0},$settings['slideSpeed']*1000);setTimeout(function(){currentView.stop(true,true).css('top',$container.outerHeight(true))},$settings['slideSpeed']*1000);break;case'slideUp':nextView.css({top:$content.height(),left:0});currentView.animate({top:-currentView.outerHeight(true)},$settings['slideSpeed']*1000);nextView.animate({top:0},$settings['slideSpeed']*1000);setTimeout(function(){currentView.stop(true,true).css('top',$container.outerHeight(true))},$settings['slideSpeed']*1000);break;case'slideDown':nextView.css({top:-$content.height(),left:0});currentView.animate({top:currentView.outerHeight(true)},$settings['slideSpeed']*1000);nextView.animate({top:0},$settings['slideSpeed']*1000);setTimeout(function(){currentView.stop(true,true).css('top',$container.outerHeight(true))},$settings['slideSpeed']*1000);break;case'fade':nextView.css({top:0,left:0,display:'none'});currentView.fadeOut(($settings['slideSpeed']*1000)/2);setTimeout(function(){nextView.fadeIn(($settings['slideSpeed']*1000)/2);currentView.stop(true,true).css({top:$container.outerHeight(true),display:'block'})},($settings['slideSpeed']*1000)/2);break;case'directFade':nextView.css({top:0,left:0,'z-index':0,display:'none'});currentView.css({'z-index':1});nextView.fadeIn($settings['slideSpeed']*1000);currentView.fadeOut($settings['slideSpeed']*1000);setTimeout(function(){nextView.stop(true,true).css({'z-index':'auto'});currentView.stop(true,true).css({top:$container.outerHeight(true),display:'block','z-index':'auto'})},$settings['slideSpeed']*1000);break}setTimeout(function(){$visibleViews=[viewId]},$settings['slideSpeed']*1000);setTimeout(function(){$navigationActive=true},$settings['slideSpeed']*1000)}function recalculate(recalculateViews){if(!$container.is(':visible')){$invisibilityTimer=setInterval(function(){if($container.is(':visible')){recalculate();clearInterval($invisibilityTimer);$invisibilityTimer=''}},500);return}var parentElement=$parentElement;for(var i=0;parentElement.width()<=0;i++){parentElement=parentElement.parent();if(i>50)break}if($currentWidth==parentElement.width())return;$currentWidth=parentElement.width();var width=parentElement.width()-($container.outerWidth(true)-$container.width());if($settings['maxWidth']>0&&$settings['maxWidth']<width)width=$settings['maxWidth'];$container.css('width',Math.floor(width));$content.css('width',Math.floor(width)-($content.outerWidth(true)-$content.width()));if($settings['preserveSlideshowDimensions']){var height=(width*$settings['dimensionHeight'])/$settings['dimensionWidth'];$container.css('height',Math.floor(height));$content.css('height',Math.floor(height)-($content.outerHeight(true)-$content.height()))}else{$container.css('height',Math.floor($settings['height']));$content.css('height',Math.floor($settings['height']))}$views.each(function(viewId,view){if($.inArray(viewId,$visibleViews)<0)$(view).css('top',$container.outerHeight(true))});if(recalculateViews||recalculateViews==undefined){recalculateVisibleViews()}}function recalculateVisibleViews(){$.each($visibleViews,function(key,viewId){recalculateView(viewId)})}function recalculateView(viewId){view=$($views[viewId]);if($content.width()==view.outerWidth(true))return;var slides=view.find('.slideshow_slide');if(slides.length<=0)return;var viewWidth=$content.width()-(view.outerWidth(true)-view.width());var viewHeight=$content.height()-(view.outerHeight(true)-view.height());var slideWidth=Math.floor(viewWidth/slides.length);var slideHeight=viewHeight;var spareWidth=viewWidth%slides.length;var totalWidth=0;$(slides[0]).css('margin-left',0);$(slides[slides.length-1]).css('margin-right',0);$.each(slides,function(slideId,slide){slide=$(slide);var outerWidth=slide.outerWidth(true)-slide.width();var outerHeight=slide.outerHeight(true)-slide.height();if(slideId==(slides.length-1))slide.width((slideWidth-outerWidth)+spareWidth);else slide.width(slideWidth-outerWidth);slide.height(slideHeight-outerHeight);if(slide.hasClass('slideshow_slide_text')){var anchor=slide.find('a');if(anchor.length<=0)return;var anchorWidth=slide.width()-(anchor.outerWidth(true)-anchor.width());var anchorHeight=slide.height()-(anchor.outerHeight(true)-anchor.height());anchor.css({'width':anchorWidth,'height':anchorHeight})}else if(slide.hasClass('slideshow_slide_image')){var image=slide.find('img');if(image.length<=0)return;var maxImageWidth=slide.width()-(image.outerWidth(true)-image.width());var maxImageHeight=slide.height()-(image.outerHeight(true)-image.height());if($settings['stretchImages']){image.css({width:maxImageWidth,height:maxImageHeight});image.attr({width:maxImageWidth,height:maxImageHeight})}else if(image.width()>0&&image.height()>0){var imageDimension=$viewData[viewId][slideId]['imageDimension'];if(imageDimension=='')imageDimension=$viewData[viewId][slideId]['imageDimension']=image.outerWidth(true)/image.outerHeight(true);var slideDimension=slide.width()/slide.height();if(imageDimension>slideDimension){image.css({'margin':'0px','width':maxImageWidth,'height':Math.floor(maxImageWidth/imageDimension)});image.attr({width:maxImageWidth,height:Math.floor(maxImageWidth/imageDimension)})}else if(imageDimension<slideDimension){image.css({'margin-left':'auto','margin-right':'auto','display':'block','width':Math.floor(maxImageHeight*imageDimension),'height':maxImageHeight});image.attr({width:Math.floor(maxImageHeight*imageDimension),height:maxImageHeight})}}}else if(slide.hasClass('slideshow_slide_video')){var videoElement=slide.find('iframe');if(videoElement.length>0){videoElement.attr({width:slide.width(),height:slide.height()})}else{var youtubePlayerReadyTimer='';youtubePlayerReadyTimer=setInterval(function(){if(!window.slideshow_jquery_image_gallery_youtube_api_ready)return;var element=slide.find('div');element.attr('id','slideshow_slide_video_'+Math.floor(Math.random()*1000000)+'_'+element.text());var player=new YT.Player(element.attr('id'),{width:$(slide).width(),height:$(slide).height(),videoId:element.text(),events:{'onReady':function(){},'onStateChange':function(event){$videoPlayers[element.attr('id')].state=event.data}}});$('#'+element.attr('id')).show();$videoPlayers[element.attr('id')]={'player':player,'state':-1};clearInterval(youtubePlayerReadyTimer)},500)}}totalWidth+=slide.outerWidth(true)});view.css({'width':viewWidth,'height':viewHeight})}function videoIsPlaying(){var videoIsPlaying=false;for(var playerID in $videoPlayers){if(!$videoPlayers.hasOwnProperty(playerID))continue;var state=$videoPlayers[playerID].state;if(state==1||state==3){videoIsPlaying=true;break}}return videoIsPlaying}function pauseAllVideos(){for(var playerID in $videoPlayers){if(!$videoPlayers.hasOwnProperty(playerID))continue;var player=$videoPlayers[playerID].player;if(player!=null&&typeof player.pauseVideo==='function'){$videoPlayers[playerID].state=2;player.pauseVideo()}}}function activateDescriptions(){if(!$settings['showDescription'])return;$.each($slides.find('.slideshow_description'),function(key,description){$(description).show();if($settings['hideDescription'])$(description).css({'position':'absolute','bottom':-$(description).outerHeight(true)})});if(!$settings['hideDescription'])return;$container.bind('onSlideshowAnimate',function(){if($visibleViews[1]==undefined)return;$.each($($views[$visibleViews[1]]).find('.slideshow_description'),function(key,description){$(description).css('bottom',-$(description).outerHeight(true))})});$slides.mouseenter(function(){$(this).find('.slideshow_description').stop(true,true).animate({'bottom':0},parseInt($settings['descriptionSpeed']*1000))});$slides.mouseleave(function(){$(this).find('.slideshow_description').stop(true,true).animate({'bottom':-$(this).outerHeight(true)},parseInt($settings['descriptionSpeed']*1000))})}function activateNavigationButtons(){if(!$settings['controllable'])return;$nextButton.click(function(){if(!$navigationActive)return;pauseAllVideos();stop();animateTo(getNextViewId(),1);start()});$previousButton.click(function(){if(!$navigationActive)return;pauseAllVideos();stop();animateTo(getPreviousViewId(),-1);start()});if($settings['hideNavigationButtons']){$container.mouseenter(function(){$nextButton.stop(true,true).fadeIn(100)});$container.mouseleave(function(){$nextButton.stop(true,true).fadeOut(500)});$container.mouseenter(function(){$previousButton.stop(true,true).fadeIn(100)});$container.mouseleave(function(){$previousButton.stop(true,true).fadeOut(500)})}else{$nextButton.show();$previousButton.show()}}function activateControlPanel(){if(!$settings['controlPanel'])return;if($settings['play'])$togglePlayButton.attr('class','slideshow_pause');else $togglePlayButton.attr('class','slideshow_play');$togglePlayButton.click(function(){if($settings['play']){$settings['play']=false;$(this).attr('class','slideshow_play');stop()}else{$settings['play']=true;$(this).attr('class','slideshow_pause');start()}});if($settings['hideControlPanel']){$container.mouseenter(function(){$controlPanel.stop(true,true).fadeIn(100)});$container.mouseleave(function(){$controlPanel.stop(true,true).fadeOut(500)})}else{$controlPanel.show()}}function activatePagination(){if(!$settings['showPagination'])return;var ul=$pagination.find('ul');ul.html('');$views.each(function(key,view){var currentView='';if(key==$currentViewId)currentView='slideshow_currentView';ul.append('<li class="slideshow_transparent '+currentView+'">'+'<span style="display: none;">'+key+'</span>'+'</li>')});$pagination.find('li').click(function(){if(!$navigationActive)return;var viewId=$(this).find('span').text();if(viewId==''||viewId==undefined)return;pauseAllVideos();stop();animateTo(parseInt(viewId),0);start()});$container.bind('onSlideshowAnimate',function(){var bullets=$pagination.find('li');bullets.each(function(key,bullet){$(bullet).removeClass('slideshow_currentView')});$(bullets[$currentViewId]).addClass('slideshow_currentView')});if($settings['hidePagination']){$container.mouseenter(function(){$pagination.stop(true,true).fadeIn(100)});$container.mouseleave(function(){$pagination.stop(true,true).fadeOut(500)})}else{$pagination.show()}}function activatePauseOnHover(){if(!$settings['pauseOnHover'])return;$container.mouseenter(function(){clearTimeout($mouseEnterTimer);$mouseEnterTimer=setTimeout(function(){stop()},500)});$container.mouseleave(function(){clearTimeout($mouseEnterTimer);if($interval===false)start()})}function getNextViewId(){if($settings['random']){var oldViewId=viewId;viewId=Math.floor(Math.random()*$views.length);if(viewId!=oldViewId)return viewId}var viewId=$currentViewId;if(viewId==undefined)return 0;if(viewId>=$views.length-1){if($settings['loop'])return viewId=0;else return $currentViewId}return viewId+=1}function getPreviousViewId(){var viewId=$currentViewId;if(viewId==undefined)viewId=0;if($settings['random']){var oldViewId=viewId;viewId=Math.floor(Math.random()*$views.length);if(viewId!=oldViewId)return viewId}if(viewId<=0){if($settings['loop'])return viewId=$views.length-1;else return $currentViewId}return viewId-=1}function getID(){var splitClasses=$container.attr('class').split('_');return splitClasses[splitClasses.length-1]}};jQuery(document).ready(function(){jQuery.each(jQuery('.slideshow_container'),function(key,slideshow){jQuery(slideshow).slideshow_jquery_image_gallery_script()});var tag=document.createElement('script');tag.src="//www.youtube.com/iframe_api";var firstScriptTag=document.getElementsByTagName('script')[0];firstScriptTag.parentNode.insertBefore(tag,firstScriptTag)});window.slideshow_jquery_image_gallery_youtube_api_ready=false;function onYouTubeIframeAPIReady(){window.slideshow_jquery_image_gallery_youtube_api_ready=true}
1
+ jQuery.fn.slideshow_jquery_image_gallery_script=function(){var $=jQuery;var $container=$(this),$content=$container.find('.slideshow_content'),$views=$container.find('.slideshow_view'),$slides=$container.find('.slideshow_slide'),$controlPanel=$container.find('.slideshow_controlPanel'),$togglePlayButton=$controlPanel.find('.slideshow_togglePlay'),$nextButton=$container.find('.slideshow_next'),$previousButton=$container.find('.slideshow_previous'),$pagination=$container.find('.slideshow_pagination');var $ID=getID();var $settings=window['SlideshowPluginSettings_'+$ID];$.each($settings,function(setting,value){if(value=='true')$settings[setting]=true;else if(value=='false')$settings[setting]=false});var $parentElement=$container.parent(),$viewData=[],$navigationActive=true,$currentViewId=getNextViewId(),$currentWidth=0,$visibleViews=[$currentViewId],$videoPlayers=[],$interval='',$mouseEnterTimer='',$invisibilityTimer='';init();function init(){recalculate(false);$.each($views,function(viewId,view){recalculateView(view);if(viewId!=$visibleViews[0])$(view).css('top',$container.outerHeight(true));$viewData[viewId]=[];$.each($(view).find('.slideshow_slide'),function(slideId,slide){$viewData[viewId][slideId]={'imageDimension':''}})});$content.show();$(window).load(function(){recalculateVisibleViews()});if($settings['enableResponsiveness']){$(window).resize(function(){recalculate()})}if(parseFloat($settings['intervalSpeed'])<parseFloat($settings['slideSpeed'])+0.1)$settings['intervalSpeed']=parseFloat($settings['slideSpeed'])+0.1;activateDescriptions();activateControlPanel();activateNavigationButtons();activatePagination();activatePauseOnHover();start()}function start(){if(!$settings['play'])return;$interval=setInterval(function(){animateTo(getNextViewId(),1)},$settings['intervalSpeed']*1000)}function stop(){clearInterval($interval);$interval=false}function animateTo(viewId,direction){if(videoIsPlaying()||viewId<0||viewId>=$views.length||viewId==$currentViewId)return;$navigationActive=false;if(direction==0||direction==undefined){if(viewId<$currentViewId)direction=-1;else direction=1}$visibleViews=[$currentViewId,viewId];var animation=$settings['animation'];var animations=['slide','slideRight','slideUp','slideDown','fade','directFade'];if(animation=='random')animation=animations[Math.floor(Math.random()*animations.length)];var animationOpposites={'slide':'slideRight','slideRight':'slide','slideUp':'slideDown','slideDown':'slideUp','fade':'fade','directFade':'directFade'};if(direction<0)animation=animationOpposites[animation];var currentView=$($views[$currentViewId]);var nextView=$($views[viewId]);currentView.stop(true,true);nextView.stop(true,true);recalculateVisibleViews();$currentViewId=viewId;$container.trigger('onSlideshowAnimate');switch(animation){case'slide':recalculateVisibleViews();nextView.css({top:0,left:$content.width()});currentView.animate({left:-currentView.outerWidth(true)},$settings['slideSpeed']*1000);nextView.animate({left:0},$settings['slideSpeed']*1000);setTimeout(function(){currentView.stop(true,true).css('top',$container.outerHeight(true))},$settings['slideSpeed']*1000);break;case'slideRight':nextView.css({top:0,left:-$content.width()});currentView.animate({left:currentView.outerWidth(true)},$settings['slideSpeed']*1000);nextView.animate({left:0},$settings['slideSpeed']*1000);setTimeout(function(){currentView.stop(true,true).css('top',$container.outerHeight(true))},$settings['slideSpeed']*1000);break;case'slideUp':nextView.css({top:$content.height(),left:0});currentView.animate({top:-currentView.outerHeight(true)},$settings['slideSpeed']*1000);nextView.animate({top:0},$settings['slideSpeed']*1000);setTimeout(function(){currentView.stop(true,true).css('top',$container.outerHeight(true))},$settings['slideSpeed']*1000);break;case'slideDown':nextView.css({top:-$content.height(),left:0});currentView.animate({top:currentView.outerHeight(true)},$settings['slideSpeed']*1000);nextView.animate({top:0},$settings['slideSpeed']*1000);setTimeout(function(){currentView.stop(true,true).css('top',$container.outerHeight(true))},$settings['slideSpeed']*1000);break;case'fade':nextView.css({top:0,left:0,display:'none'});currentView.fadeOut(($settings['slideSpeed']*1000)/2);setTimeout(function(){nextView.fadeIn(($settings['slideSpeed']*1000)/2);currentView.stop(true,true).css({top:$container.outerHeight(true),display:'block'})},($settings['slideSpeed']*1000)/2);break;case'directFade':nextView.css({top:0,left:0,'z-index':0,display:'none'});currentView.css({'z-index':1});nextView.fadeIn($settings['slideSpeed']*1000);currentView.fadeOut($settings['slideSpeed']*1000);setTimeout(function(){nextView.stop(true,true).css({'z-index':'auto'});currentView.stop(true,true).css({top:$container.outerHeight(true),display:'block','z-index':'auto'})},$settings['slideSpeed']*1000);break}setTimeout(function(){$visibleViews=[viewId]},$settings['slideSpeed']*1000);setTimeout(function(){$navigationActive=true},$settings['slideSpeed']*1000)}function recalculate(recalculateViews){if(!$container.is(':visible')){$invisibilityTimer=setInterval(function(){if($container.is(':visible')){recalculate();clearInterval($invisibilityTimer);$invisibilityTimer=''}},500);return}var parentElement=$parentElement;for(var i=0;parentElement.width()<=0;i++){parentElement=parentElement.parent();if(i>50)break}if($currentWidth==parentElement.width())return;$currentWidth=parentElement.width();var width=parentElement.width()-($container.outerWidth(true)-$container.width());if($settings['maxWidth']>0&&$settings['maxWidth']<width)width=$settings['maxWidth'];$container.css('width',Math.floor(width));$content.css('width',Math.floor(width)-($content.outerWidth(true)-$content.width()));if($settings['preserveSlideshowDimensions']){var height=(width*$settings['dimensionHeight'])/$settings['dimensionWidth'];$container.css('height',Math.floor(height));$content.css('height',Math.floor(height)-($content.outerHeight(true)-$content.height()))}else{$container.css('height',Math.floor($settings['height']));$content.css('height',Math.floor($settings['height']))}$views.each(function(viewId,view){if($.inArray(viewId,$visibleViews)<0)$(view).css('top',$container.outerHeight(true))});if(recalculateViews||recalculateViews==undefined){recalculateVisibleViews()}}function recalculateVisibleViews(){$.each($visibleViews,function(key,viewId){recalculateView(viewId)})}function recalculateView(viewId){view=$($views[viewId]);if($content.width()==view.outerWidth(true))return;var slides=view.find('.slideshow_slide');if(slides.length<=0)return;var viewWidth=$content.width()-(view.outerWidth(true)-view.width());var viewHeight=$content.height()-(view.outerHeight(true)-view.height());var slideWidth=Math.floor(viewWidth/slides.length);var slideHeight=viewHeight;var spareWidth=viewWidth%slides.length;var totalWidth=0;$(slides[0]).css('margin-left',0);$(slides[slides.length-1]).css('margin-right',0);$.each(slides,function(slideId,slide){slide=$(slide);var outerWidth=slide.outerWidth(true)-slide.width();var outerHeight=slide.outerHeight(true)-slide.height();if(slideId==(slides.length-1))slide.width((slideWidth-outerWidth)+spareWidth);else slide.width(slideWidth-outerWidth);slide.height(slideHeight-outerHeight);if(slide.hasClass('slideshow_slide_text')){var anchor=slide.find('a');if(anchor.length<=0)return;var anchorWidth=slide.width()-(anchor.outerWidth(true)-anchor.width());var anchorHeight=slide.height()-(anchor.outerHeight(true)-anchor.height());anchor.css({'width':anchorWidth,'height':anchorHeight})}else if(slide.hasClass('slideshow_slide_image')){var image=slide.find('img');if(image.length<=0)return;var maxImageWidth=slide.width()-(image.outerWidth(true)-image.width());var maxImageHeight=slide.height()-(image.outerHeight(true)-image.height());if($settings['stretchImages']){image.css({width:maxImageWidth,height:maxImageHeight});image.attr({width:maxImageWidth,height:maxImageHeight})}else if(image.width()>0&&image.height()>0){var imageDimension=$viewData[viewId][slideId]['imageDimension'];if(imageDimension=='')imageDimension=$viewData[viewId][slideId]['imageDimension']=image.outerWidth(true)/image.outerHeight(true);var slideDimension=slide.width()/slide.height();if(imageDimension>slideDimension){image.css({'margin':'0px','width':maxImageWidth,'height':Math.floor(maxImageWidth/imageDimension)});image.attr({width:maxImageWidth,height:Math.floor(maxImageWidth/imageDimension)})}else if(imageDimension<slideDimension){image.css({'margin-left':'auto','margin-right':'auto','display':'block','width':Math.floor(maxImageHeight*imageDimension),'height':maxImageHeight});image.attr({width:Math.floor(maxImageHeight*imageDimension),height:maxImageHeight})}}}else if(slide.hasClass('slideshow_slide_video')){var videoElement=slide.find('iframe');if(videoElement.length>0){videoElement.attr({width:slide.width(),height:slide.height()})}else{var youtubePlayerReadyTimer='';youtubePlayerReadyTimer=setInterval(function(){if(!window.slideshow_jquery_image_gallery_youtube_api_ready)return;var element=slide.find('div');element.attr('id','slideshow_slide_video_'+Math.floor(Math.random()*1000000)+'_'+element.text());var player=new YT.Player(element.attr('id'),{width:$(slide).width(),height:$(slide).height(),videoId:element.text(),playerVars:{wmode:'opaque'},events:{'onReady':function(){},'onStateChange':function(event){$videoPlayers[element.attr('id')].state=event.data}}});playerElement=$('#'+element.attr('id'));playerElement.show();playerElement.attr('src',playerElement.attr('src')+'&wmode=opaque');$videoPlayers[element.attr('id')]={'player':player,'state':-1};clearInterval(youtubePlayerReadyTimer)},500)}}totalWidth+=slide.outerWidth(true)});view.css({'width':viewWidth,'height':viewHeight})}function videoIsPlaying(){var videoIsPlaying=false;for(var playerID in $videoPlayers){if(!$videoPlayers.hasOwnProperty(playerID))continue;var state=$videoPlayers[playerID].state;if(state==1||state==3){videoIsPlaying=true;break}}return videoIsPlaying}function pauseAllVideos(){for(var playerID in $videoPlayers){if(!$videoPlayers.hasOwnProperty(playerID))continue;var player=$videoPlayers[playerID].player;if(player!=null&&typeof player.pauseVideo==='function'){$videoPlayers[playerID].state=2;player.pauseVideo()}}}function activateDescriptions(){if(!$settings['showDescription'])return;$.each($slides.find('.slideshow_description'),function(key,description){$(description).show();if($settings['hideDescription'])$(description).css({'position':'absolute','bottom':-$(description).outerHeight(true)})});if(!$settings['hideDescription'])return;$container.bind('onSlideshowAnimate',function(){if($visibleViews[1]==undefined)return;$.each($($views[$visibleViews[1]]).find('.slideshow_description'),function(key,description){$(description).css('bottom',-$(description).outerHeight(true))})});$slides.mouseenter(function(){$(this).find('.slideshow_description').stop(true,true).animate({'bottom':0},parseInt($settings['descriptionSpeed']*1000))});$slides.mouseleave(function(){$(this).find('.slideshow_description').stop(true,true).animate({'bottom':-$(this).outerHeight(true)},parseInt($settings['descriptionSpeed']*1000))})}function activateNavigationButtons(){if(!$settings['controllable'])return;$nextButton.click(function(){if(!$navigationActive)return;pauseAllVideos();stop();animateTo(getNextViewId(),1);start()});$previousButton.click(function(){if(!$navigationActive)return;pauseAllVideos();stop();animateTo(getPreviousViewId(),-1);start()});if($settings['hideNavigationButtons']){$container.mouseenter(function(){$nextButton.stop(true,true).fadeIn(100)});$container.mouseleave(function(){$nextButton.stop(true,true).fadeOut(500)});$container.mouseenter(function(){$previousButton.stop(true,true).fadeIn(100)});$container.mouseleave(function(){$previousButton.stop(true,true).fadeOut(500)})}else{$nextButton.show();$previousButton.show()}}function activateControlPanel(){if(!$settings['controlPanel'])return;if($settings['play'])$togglePlayButton.attr('class','slideshow_pause');else $togglePlayButton.attr('class','slideshow_play');$togglePlayButton.click(function(){if($settings['play']){$settings['play']=false;$(this).attr('class','slideshow_play');stop()}else{$settings['play']=true;$(this).attr('class','slideshow_pause');start()}});if($settings['hideControlPanel']){$container.mouseenter(function(){$controlPanel.stop(true,true).fadeIn(100)});$container.mouseleave(function(){$controlPanel.stop(true,true).fadeOut(500)})}else{$controlPanel.show()}}function activatePagination(){if(!$settings['showPagination'])return;var ul=$pagination.find('ul');ul.html('');$views.each(function(key,view){var currentView='';if(key==$currentViewId)currentView='slideshow_currentView';ul.append('<li class="slideshow_transparent '+currentView+'">'+'<span style="display: none;">'+key+'</span>'+'</li>')});$pagination.find('li').click(function(){if(!$navigationActive)return;var viewId=$(this).find('span').text();if(viewId==''||viewId==undefined)return;pauseAllVideos();stop();animateTo(parseInt(viewId),0);start()});$container.bind('onSlideshowAnimate',function(){var bullets=$pagination.find('li');bullets.each(function(key,bullet){$(bullet).removeClass('slideshow_currentView')});$(bullets[$currentViewId]).addClass('slideshow_currentView')});if($settings['hidePagination']){$container.mouseenter(function(){$pagination.stop(true,true).fadeIn(100)});$container.mouseleave(function(){$pagination.stop(true,true).fadeOut(500)})}else{$pagination.show()}}function activatePauseOnHover(){if(!$settings['pauseOnHover'])return;$container.mouseenter(function(){clearTimeout($mouseEnterTimer);$mouseEnterTimer=setTimeout(function(){stop()},500)});$container.mouseleave(function(){clearTimeout($mouseEnterTimer);if($interval===false)start()})}function getNextViewId(){if($settings['random']){var oldViewId=viewId;viewId=Math.floor(Math.random()*$views.length);if(viewId!=oldViewId)return viewId}var viewId=$currentViewId;if(viewId==undefined)return 0;if(viewId>=$views.length-1){if($settings['loop'])return viewId=0;else return $currentViewId}return viewId+=1}function getPreviousViewId(){var viewId=$currentViewId;if(viewId==undefined)viewId=0;if($settings['random']){var oldViewId=viewId;viewId=Math.floor(Math.random()*$views.length);if(viewId!=oldViewId)return viewId}if(viewId<=0){if($settings['loop'])return viewId=$views.length-1;else return $currentViewId}return viewId-=1}function getID(){var splitClasses=$container.attr('class').split('_');return splitClasses[splitClasses.length-1]}};jQuery(document).ready(function(){jQuery.each(jQuery('.slideshow_container'),function(key,slideshow){jQuery(slideshow).slideshow_jquery_image_gallery_script()});var tag=document.createElement('script');tag.src="//www.youtube.com/iframe_api";var firstScriptTag=document.getElementsByTagName('script')[0];firstScriptTag.parentNode.insertBefore(tag,firstScriptTag)});window.slideshow_jquery_image_gallery_youtube_api_ready=false;function onYouTubeIframeAPIReady(){window.slideshow_jquery_image_gallery_youtube_api_ready=true}
js/SlideshowPluginSlideInserter/slide-inserter.js CHANGED
@@ -144,27 +144,36 @@ jQuery(document).ready(function(){
144
  * @param offset (optional, defaults to 0)
145
  */
146
  function slideshowSlideInserterGetSearchResults(offset){
 
 
 
147
  if(!offset){
148
  offset = 0;
149
- jQuery('#slideshow-slide-inserter-popup #results').html('');
150
  }
151
 
 
 
 
 
 
152
  jQuery.post(
153
  ajaxurl,
154
  {
155
  action: 'slideshow_slide_inserter_search_query',
156
- search: jQuery('#slideshow-slide-inserter-popup #search').attr('value'),
157
- offset: offset
 
158
  },
159
  function(response){
160
  // Fill table
161
- jQuery('#slideshow-slide-inserter-popup #results').append(response);
162
 
163
  // Apply insert to slideshow script
164
- jQuery('#slideshow-slide-inserter-popup #results .insert-attachment').click(function(){
165
  var tr = jQuery(this).closest('tr');
166
  slideshowSlideInserterInsertImageSlide(
167
- jQuery(this).attr('id'),
168
  jQuery(tr).find('.title').text(),
169
  jQuery(tr).find('.description').text(),
170
  jQuery(tr).find('.image img').attr('src')
@@ -172,8 +181,9 @@ jQuery(document).ready(function(){
172
  });
173
 
174
  // Load more results on click of the 'Load more results' button
175
- if(jQuery('.load-more-results')){
176
- jQuery('.load-more-results').click(function(){
 
177
  // Get offset
178
  var previousOffset = jQuery(this).attr('class').split(' ')[2];
179
 
144
  * @param offset (optional, defaults to 0)
145
  */
146
  function slideshowSlideInserterGetSearchResults(offset){
147
+ var popup = jQuery('#slideshow-slide-inserter-popup');
148
+ var resultsTable = popup.find('#results');
149
+
150
  if(!offset){
151
  offset = 0;
152
+ resultsTable.html('');
153
  }
154
 
155
+ var attachmentIDs = [];
156
+ jQuery.each(resultsTable.find('.result-table-row'), function(key, tr){
157
+ attachmentIDs.push(jQuery(tr).data('attachmentId'));
158
+ });
159
+
160
  jQuery.post(
161
  ajaxurl,
162
  {
163
  action: 'slideshow_slide_inserter_search_query',
164
+ search: popup.find('#search').attr('value'),
165
+ offset: offset,
166
+ attachmentIDs: attachmentIDs
167
  },
168
  function(response){
169
  // Fill table
170
+ resultsTable.append(response);
171
 
172
  // Apply insert to slideshow script
173
+ resultsTable.find('.insert-attachment').unbind('click').click(function(){
174
  var tr = jQuery(this).closest('tr');
175
  slideshowSlideInserterInsertImageSlide(
176
+ jQuery(tr).data('attachmentId'),
177
  jQuery(tr).find('.title').text(),
178
  jQuery(tr).find('.description').text(),
179
  jQuery(tr).find('.image img').attr('src')
181
  });
182
 
183
  // Load more results on click of the 'Load more results' button
184
+ var loadMoreResultsButton = jQuery('.load-more-results');
185
+ if(loadMoreResultsButton){
186
+ loadMoreResultsButton.click(function(){
187
  // Get offset
188
  var previousOffset = jQuery(this).attr('class').split(' ')[2];
189
 
readme.txt CHANGED
@@ -5,7 +5,7 @@ Donate link: http://stefanboonstra.com/donate-to-slideshow/
5
  Tags: slideshow, slider, slide, slides, show, images, image, photo, gallery, galleries, jquery, javascript, video, text
6
  Requires at least: 3.3
7
  Tested up to: 3.5.1
8
- Stable tag: 2.2.6
9
  License: GPLv2
10
 
11
  Integrate a fancy slideshow in just five steps. - Rainbows. Rainbows everywhere.
@@ -165,6 +165,11 @@ personal taste.
165
 
166
  == Changelog ==
167
 
 
 
 
 
 
168
  = 2.2.6 =
169
  * Fixed: Theme's that set image heights affected the slideshow's image dimensions.
170
  * Fixed: Compatibility with the ALO EasyMail Newsletter plugin.
5
  Tags: slideshow, slider, slide, slides, show, images, image, photo, gallery, galleries, jquery, javascript, video, text
6
  Requires at least: 3.3
7
  Tested up to: 3.5.1
8
+ Stable tag: 2.2.7
9
  License: GPLv2
10
 
11
  Integrate a fancy slideshow in just five steps. - Rainbows. Rainbows everywhere.
165
 
166
  == Changelog ==
167
 
168
+ = 2.2.7 =
169
+ * Fixed: Slideshow control buttons were placed behind the slideshow.
170
+ * Fixed: Image slides doubly inserted after having clicked on 'Load more results'
171
+ * Included width and height attributes on all image elements.
172
+
173
  = 2.2.6 =
174
  * Fixed: Theme's that set image heights affected the slideshow's image dimensions.
175
  * Fixed: Compatibility with the ALO EasyMail Newsletter plugin.
slideshow.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Slideshow
4
  Plugin URI: http://wordpress.org/extend/plugins/slideshow-jquery-image-gallery/
5
  Description: The slideshow plugin is easily deployable on your website. Add any image that has already been uploaded to add to your slideshow, add text slides, or even add a video. Options and styles are customizable for every single slideshow on your website.
6
- Version: 2.2.6
7
  Requires at least: 3.3
8
  Author: StefanBoonstra
9
  Author URI: http://stefanboonstra.com/
@@ -22,7 +22,7 @@
22
  class SlideshowPluginMain {
23
 
24
  /** Variables */
25
- static $version = '2.2.6';
26
 
27
  /**
28
  * Bootstraps the application by assigning the right functions to
3
  Plugin Name: Slideshow
4
  Plugin URI: http://wordpress.org/extend/plugins/slideshow-jquery-image-gallery/
5
  Description: The slideshow plugin is easily deployable on your website. Add any image that has already been uploaded to add to your slideshow, add text slides, or even add a video. Options and styles are customizable for every single slideshow on your website.
6
+ Version: 2.2.7
7
  Requires at least: 3.3
8
  Author: StefanBoonstra
9
  Author URI: http://stefanboonstra.com/
22
  class SlideshowPluginMain {
23
 
24
  /** Variables */
25
+ static $version = '2.2.7';
26
 
27
  /**
28
  * Bootstraps the application by assigning the right functions to
views/SlideshowPluginSlideshowSlide/frontend_attachment.php CHANGED
@@ -32,14 +32,21 @@ if(is_numeric($postId)):
32
  // Prepare image
33
  $image = wp_get_attachment_image_src($attachment->ID, 'full');
34
  $imageSrc = '';
 
 
35
  $imageAvailable = true;
36
- if(!is_array($image) || !$image){
37
  if(!empty($attachment->guid))
38
  $imageSrc = $attachment->guid;
39
  else
40
  $imageAvailable = false;
41
  }else{
42
  $imageSrc = $image[0];
 
 
 
 
 
43
  }
44
 
45
  // If image is available
@@ -47,7 +54,7 @@ if(is_numeric($postId)):
47
 
48
  <div class="slideshow_slide slideshow_slide_image">
49
  <a <?php echo $anchorTagAttributes; ?>>
50
- <img src="<?php echo htmlspecialchars($imageSrc); ?>" alt="<?php echo $alt; ?>">
51
  </a>
52
  <div class="slideshow_description slideshow_transparent">
53
  <a <?php echo $anchorTagAttributes; ?>>
32
  // Prepare image
33
  $image = wp_get_attachment_image_src($attachment->ID, 'full');
34
  $imageSrc = '';
35
+ $imageWidth = 0;
36
+ $imageHeight = 0;
37
  $imageAvailable = true;
38
+ if(!is_array($image) || !$image || !isset($image[0])){
39
  if(!empty($attachment->guid))
40
  $imageSrc = $attachment->guid;
41
  else
42
  $imageAvailable = false;
43
  }else{
44
  $imageSrc = $image[0];
45
+
46
+ if(isset($image[1], $image[2])){
47
+ $imageWidth = $image[1];
48
+ $imageHeight = $image[2];
49
+ }
50
  }
51
 
52
  // If image is available
54
 
55
  <div class="slideshow_slide slideshow_slide_image">
56
  <a <?php echo $anchorTagAttributes; ?>>
57
+ <img src="<?php echo htmlspecialchars($imageSrc); ?>" alt="<?php echo $alt; ?>" width="<?php echo $imageWidth ?>" height="<?php echo $imageHeight; ?>">
58
  </a>
59
  <div class="slideshow_description slideshow_transparent">
60
  <a <?php echo $anchorTagAttributes; ?>>