Advertisement
Guest User

WPBR 81177

a guest
Aug 23rd, 2018
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.74 KB | None | 0 0
  1. function rb_getGalleryThumbs($postID=''){
  2.     $re = '';
  3.     if(is_single() || is_category() || is_tag() || is_archive() || is_search() || is_404())
  4.         return '&lt;ul id="bgImages" data-gallery-id="0"&gt;</ul>';
  5.     global $wpdb;
  6.     $fpgalleryid = get_option('defaultGallery');
  7.    
  8.     if(!empty($postID)){
  9.         $pageGalleryID = get_post_meta($postID, "pageGalleryId", true);
  10.         if(!(empty($pageGalleryID) || $pageGalleryID=='Default') )
  11.             $fpgalleryid = $pageGalleryID;
  12.         if($fpgalleryid=='NoGallery') $fpgalleryid = '';
  13.     }
  14.     if(empty($fpgalleryid)) $fpgalleryid = 0;
  15.  
  16.     $re .= '&lt;ul id="bgImages" data-gallery-id="'.$fpgalleryid.'"&gt;'."\n";
  17.     if(!empty($fpgalleryid))
  18.     {
  19.         $rb_gallery_post = get_post($fpgalleryid);
  20.         if(isset($rb_gallery_post-&gt;post_content))
  21.         {
  22.             $rb_gallery_content = $rb_gallery_post-&gt;post_content;
  23.             $rb_gallery_array = rb_sh2array($rb_gallery_content);
  24.             if($rb_gallery_array[0]['shortcode']=='rb_gallery')
  25.             {
  26.                 foreach($rb_gallery_array[0]['content'] as $item)
  27.                 {
  28.                     if($item['shortcode']=='rb_gallery_item'){
  29.                         $re .= "\t\t\t".'<li>'."\n";
  30.                         $attr =$item['attr'];
  31.                        
  32.                         if($attr['type']=='image')
  33.                             $re .= "\t\t\t\t".'<a href="'.$attr['url'].'" title="'.$attr['caption'].'">'."\n";
  34.                         elseif($attr['type']=='video'){
  35.                             $video_type = rb_getMediaType($attr['url']);
  36.                             $video_id = rb_getParamsFromUrl($attr['url']);
  37.                            
  38.                             if($video_type=='vimeo')
  39.                                 $re .= "\t\t\t\t".'<a href="http://vimeo.com/'.$video_id['v'].'?width='.$attr['width'].'&amp;height='.$attr['height'].'">'."\n";
  40.                             elseif($video_type=='youtube')
  41.                                 $re .= "\t\t\t\t".'<a href="http://youtu.be/'.$video_id['v'].'?width='.$attr['width'].'&amp;height='.$attr['height'].'">'."\n";
  42.                             else{
  43.                                 $poster='';
  44.                                 if(!empty($attr['thumbnail']))
  45.                                     $poster = '&amp;poster='.$attr['thumbnail'];
  46.                                 $re .= "\t\t\t\t".'<a href="'.$attr['url'].'?width='.$attr['width'].'&amp;height='.$attr['height'].$poster.'">'."\n";
  47.                             }
  48.                         }
  49.                        
  50.                         if(function_exists('wpthumb'))
  51.                             $re .= "\t\t\t\t\t".'<img src="'.wpthumb($attr['thumbnail'],'height=120&amp;resize=true&amp;crop=1&amp;crop_from_position='.$attr['crop']).'" alt="'.$attr['caption'].'" />'."\n";
  52.                         else
  53.                             $re .= "\t\t\t\t\t".'<img src="'.$attr['thumbnail'].'" alt="'.$attr['caption'].'" />'."\n";
  54.                        
  55.                         $re .= "\t\t\t\t".'</a>'."\n";
  56.                        
  57.                         if(!empty($attr['caption']))
  58.                             $re .= "\t\t\t\t".'&lt;h3&gt;'.stripslashes($attr['caption']).'&lt;/h3&gt;'."\n";
  59.                        
  60.                         if(!empty($item['content']))
  61.                             $re .= "\t\t\t\t".'&lt;p&gt;'.stripslashes($item['content']).'&lt;/p&gt;'."\n";
  62.                        
  63.                         $re .= "\t\t\t"."</li>\n";
  64.                     }
  65.                 }
  66.             }
  67.         }
  68.     }
  69.     $re .= "\t\t".'</ul>';
  70.     return $re;
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement