Advertisement
cipher87

Flashlight Slideshow Caption

Feb 27th, 2018
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 27.12 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. class avia_gallery_slider{
  5.    
  6.     var $post_id;
  7.     var $default_image;
  8.     var $image_url_array = array();
  9.     var $image_thumb_url_array = array();
  10.     var $slideHtml = "";
  11.     var $settings = array();
  12.    
  13.     //init the background slider
  14.     function __construct($post_id = false)
  15.     {  
  16.         if(!$post_id)
  17.         {
  18.             $this->post_id = avia_get_the_ID();
  19.         }
  20.         else
  21.         {
  22.             $this->post_id = $post_id;
  23.         }
  24.        
  25.        
  26.         if(avia_is_overview())
  27.         {
  28.             $settings['gallery_layout'] = "bg_gallery";
  29.             $settings['autorotate'] = avia_get_option('slideshow_duration');
  30.             $settings['overlay'] = avia_get_option('gallery_overlay');
  31.             $settings['gallery_tooltips'] = avia_get_option('gallery_tooltips');
  32.             $settings['gallery_controlls'] = 'hide';
  33.             $settings['transition'] = avia_get_option('gallery_transition');
  34.             $settings['cropping'] = avia_get_option('gallery_cropping');
  35.             $settings['instant_gallery'] = "";
  36.            
  37.             if(!$settings['gallery_tooltips']) $settings['gallery_tooltips'] = 'all';
  38.         }
  39.         else
  40.         {
  41.                
  42.             //set layout and gallery style
  43.             $settings['layout'] = avia_post_meta($this->post_id, 'entry_layout');
  44.             $settings['gallery_layout'] = avia_post_meta($this->post_id, 'gallery_layout');
  45.            
  46.             if($settings['layout'] == 'no_content_display bg_gallery')
  47.             {
  48.                 $settings['gallery_layout'] = "bg_gallery";
  49.             }
  50.            
  51.             //set autorotation
  52.             $settings['transition'] = avia_post_meta($this->post_id, 'gallery_transition');
  53.             if($settings['transition'] == '')
  54.             {
  55.                 $settings['transition'] = avia_get_option('gallery_transition');
  56.                 if(!$settings['transition']) $settings['transition'] == 'fade';
  57.             }
  58.            
  59.             //set cropping
  60.             $settings['cropping'] = avia_post_meta($this->post_id, 'gallery_cropping');
  61.             if($settings['cropping'] == '')
  62.             {
  63.                 $settings['cropping'] = avia_get_option('gallery_cropping');
  64.             }
  65.            
  66.             //set transition
  67.             $settings['autorotate'] = avia_post_meta($this->post_id, 'slideshow_duration');
  68.             if($settings['autorotate'] == '')
  69.             {
  70.                 $settings['autorotate'] = avia_get_option('slideshow_duration');
  71.             }
  72.            
  73.             //set overlay
  74.             $settings['overlay'] = avia_post_meta($this->post_id, 'gallery_overlay');
  75.             if($settings['overlay'] == '')
  76.             {
  77.                 $settings['overlay'] = avia_get_option('gallery_overlay');
  78.             }
  79.            
  80.             //set slidecontrolls display
  81.             $settings['gallery_controlls'] = 'hide';
  82.             if(!avia_is_overview())
  83.             {
  84.                 $settings['gallery_controlls'] = avia_post_meta($this->post_id, 'gallery_controlls');
  85.                 if(!$settings['gallery_controlls']) $settings['gallery_controlls'] == 'show';
  86.             }
  87.            
  88.             //set tooltips
  89.             $settings['gallery_tooltips'] = avia_post_meta($this->post_id, 'gallery_tooltips');
  90.             if($settings['gallery_tooltips'] == '')
  91.             {
  92.                 $settings['gallery_tooltips'] = avia_get_option('gallery_tooltips');
  93.                 if(!$settings['gallery_tooltips']) $settings['gallery_tooltips'] ='all';
  94.             }
  95.            
  96.             //set tooltips
  97.             $settings['instant_gallery'] = avia_post_meta($this->post_id, 'instant_gallery');
  98.            
  99.            
  100.             if(!avia_post_meta($this->post_id, 'bg_gallery_use_default') || $settings['gallery_layout'] == 'bg_gallery')
  101.             {
  102.                 if(!post_password_required())
  103.                     {
  104.                     //get the unique id so we know which gallery to retrieve
  105.                     //$unqiue_id = avia_post_meta($this->post_id, 'gallery_image');
  106.  
  107.                     //$this->retrieve_post_images($unqiue_id);
  108.                     $this->retrieve_post_images($this->post_id);
  109.                     }
  110.                 }
  111.         }
  112.        
  113.         if(post_password_required())
  114.         {
  115.             $settings['instant_gallery'] = "";
  116.         }
  117.        
  118.        
  119.         //then try to retrieve the fallback gallery
  120.         if(empty($this->image_url_array[0])) $this->retrieve_post_images();
  121.        
  122.         //if we got no images use the default image
  123.         if(empty($this->image_url_array[0]) && avia_get_option('bg_image_repeat') == 'fullscreen') $this->image_url_array[0] = avia_get_option('bg_image');
  124.        
  125.        
  126.         //if the user cant controll the bg library and autorotation is deactivated we only need a single background image
  127.         if($settings['gallery_controlls'] == 'hide' && $settings['autorotate'] == 'false')
  128.         {
  129.             if(!empty($this->image_url_array[1]))
  130.             {
  131.                 $temp = $this->image_url_array[0];
  132.                 unset($this->image_url_array);
  133.                 $this->image_url_array[0] = $temp;
  134.             }
  135.         }
  136.                
  137.         $this->settings = $settings;
  138.     }
  139.    
  140.     //gets the hidden post of type avia_framework_post that is used to store uploads in a separate gallery
  141.     function retrieve_post_images($id = "", $size = "fullsize", $returnvalue = 'url')
  142.     {  
  143.         global $avia_config;
  144.        
  145.         if(!$id)
  146.         {
  147.             $attachment_holder = avia_get_post_by_title( "avia_smart-default-gallery");
  148.         }
  149.         else
  150.         {
  151.             $attachments = avia_post_meta($this->post_id, 'slideshow');
  152.         }
  153.        
  154.         if(empty($attachments) && empty($attachment_holder))
  155.         {  
  156.             $attachment_holder = avia_get_post_by_title( "avia_smart-gallery-of-post-".$id);
  157.         }
  158.        
  159.        
  160.         if(!empty($attachment_holder['ID'])){
  161.            
  162.             $attachments = get_children(array('post_parent' => $attachment_holder['ID'],
  163.                             'post_status' => 'inherit',
  164.                             'post_type' => 'attachment',
  165.                             'post_mime_type' => 'image',
  166.                             'order' => 'ASC',
  167.                             'orderby' => 'menu_order ID'));
  168.         }
  169.  
  170.  
  171.         if(!empty($attachments))
  172.         {
  173.             foreach($attachments as $key => $attachment)
  174.             {
  175.                 if(is_array($attachment))
  176.                 {
  177.                     $att_id = $attachment['slideshow_image'];
  178.                     $this->image_meta_content[$att_id] = $attachment;
  179.                 }
  180.                 else
  181.                 {
  182.                     $att_id = $attachment->ID;
  183.                 }
  184.            
  185.            
  186.                 $this->image_url_array[] = avia_image_by_id($att_id, $avia_config['imgSize'][$size], $returnvalue);
  187.                 $this->image_thumb_url_array[] = avia_image_by_id($att_id, $avia_config['imgSize']['widget'], 'url');
  188.                 $this->image_id_array[] = $att_id;
  189.             }
  190.         }
  191.        
  192.     }
  193.    
  194.     function instant_gal()
  195.     {
  196.         return $this->settings['instant_gallery'];
  197.     }
  198.    
  199.    
  200.     //display the background gallery
  201.     function create_HTML()
  202.     {
  203.         $output = "";
  204.        
  205.         if(!empty($this->image_url_array[0]))
  206.         {
  207.             $controlls  = $this->settings['gallery_controlls'];
  208.             $autorotate = $this->settings['autorotate'];
  209.             $transition = $this->settings['transition'];
  210.             $cropping   = $this->settings['cropping'];
  211.            
  212.             $data = " data-autorotation ='false' ";
  213.  
  214.             if($autorotate != 'false' && $autorotate != '')
  215.             {
  216.                 $data  = " data-autorotationspeed ='$autorotate' ";
  217.                 $data .= " data-autorotation ='true' ";
  218.             }
  219.            
  220.             if($controlls == 'hide')
  221.             {
  222.                 $data .= " data-appendcontrolls='false'";
  223.             }
  224.            
  225.             if($cropping != "" && $cropping != "cropping")
  226.             {
  227.                 $data .= " data-cropping='false'";
  228.             }
  229.            
  230.             $data .= " data-hide='".__('hide sidebar &amp; content','avia_framework')."'";
  231.             $data .= " data-imagecounter='".__('Image -X- from -Y-','avia_framework')."'";
  232.             $data .= " data-transition ='$transition' ";
  233.            
  234.            
  235.             $output .= "<ul class='avia_fullscreen_slider $cropping' $data >";
  236.            
  237.             $image_id_array = $this->image_id_array;
  238.            
  239.             foreach($this->image_url_array as $url)
  240.             {
  241.                
  242.                 $image_title = $this->image_meta_content[$image_id_array[0]]['slideshow_caption_title'];
  243.                 $image_description = $this->image_meta_content[$image_id_array[0]]['slideshow_caption'];
  244.                 array_shift( $image_id_array );
  245.                
  246.                 $output .= "<li data-image='$url'><div class='avia-fs-caption'><div class='avia-fs-caption-inner'>";
  247.                 if($image_title || $image_description )
  248.                 {
  249.                     if($image_title) $output .= "<strong>".$image_title."</strong>";
  250.                     if($image_description) $output .= "<div class='description'>".$image_description."</div>";
  251.                 }
  252.                 $output .= "</div></div></li>";
  253.             }
  254.                
  255.             $output .= "</ul><noscript><div id='fallbackImage' style='background-image:url($url)'></div></noscript>";
  256.         }
  257.         $this->slideHtml .= $output;
  258.     }
  259.    
  260.     function create_thumb_HTML()
  261.     {
  262.         $first = "active_thumb";
  263.         $output = "";
  264.         if(!empty($this->image_thumb_url_array[1]))
  265.         {
  266.        
  267.             $output .= "<div class='avia_fullscreen_slider_thumbs'>";
  268.             $output .= "<div class='border-transparent border-transparent-right'></div>";
  269.             $output .= "<div class='border-transparent border-transparent-top'></div>";
  270.             $output .= "<a class='slide_thumbnails no_scroll' href='#'></a>";
  271.             $output .= "<div class='avia_fullscreen_slider_thumbs_inner'>";
  272.             $output .= "<div class='avia_fullscreen_slider_thumbs_outer_slide'>";
  273.             $output .= "<div class='avia_fullscreen_slider_thumbs_inner_slide'>";
  274.            
  275.             foreach($this->image_thumb_url_array as $key => $img)
  276.             {
  277.                 $exif = $this->exif_container($this->image_id_array[$key], true);
  278.                 $output .= "<div class='fullscreen_thumb $first'><img src='$img' title='' alt='' /> $exif</div>";
  279.                 $first = "";
  280.             }
  281.                
  282.             $output .= "</div></div></div></div>";
  283.         }
  284.         $this->slideHtml .= $output;
  285.     }
  286.    
  287.     function exif_container($id, $showmeta = true)
  288.     {
  289.         $output = "";
  290.         if($this->settings['gallery_tooltips'] == 'all' || $this->settings['gallery_tooltips'] == 'title')
  291.         {
  292.            
  293.             if($this->settings['gallery_tooltips'] == 'title') $showmeta = false;
  294.             $exif = avia_exif_data($id);
  295.             $meta = "";
  296.            
  297.             if(isset($this->image_meta_content[$id]))
  298.             {
  299.                 if(isset($this->image_meta_content[$id]['slideshow_caption_title']))
  300.                     $exif['title'][1] = $this->image_meta_content[$id]['slideshow_caption_title'];
  301.                
  302.                 if(isset($this->image_meta_content[$id]['slideshow_caption']))
  303.                     $exif['description'][1] = $this->image_meta_content[$id]['slideshow_caption'];
  304.                
  305.                 if(empty($exif['title'][1])) $exif['title'] = "";
  306.                 if(empty($exif['description'][1])) $exif['description'] = "";
  307.             }
  308.            
  309.             if(!empty($exif['title']) && $exif['title'][1] == "-"){$exif['title'] = ""; $exif['description'] = ""; $showmeta = false;}
  310.  
  311.             if($exif['title'] || $exif['description'])
  312.             {
  313.                 if($exif['title']) $output .= "<strong>".$exif['title'][1]."</strong>";
  314.                 if($exif['description']) $output .= "<div class='description'>".$exif['description'][1]."</div>";
  315.             }
  316.            
  317.             if($showmeta)
  318.             {
  319.                 if($exif['camera']) $meta .= "<li class='exif-camera'><span>".$exif['camera'][0].":</span> ".$exif['camera'][1]."</li>";
  320.                 if($exif['created_timestamp']) $meta .= "<li class='exif-created_timestamp'><span>".$exif['created_timestamp'][0].":</span> ".$exif['created_timestamp'][1]."</li>";
  321.                 if($exif['copyright']) $meta .= "<li class='exif-copyright'><span>".$exif['copyright'][0].":</span> ".$exif['copyright'][1]."</li>";
  322.                 if($exif['credit']) $meta .= "<li class='exif-credit'><span>".$exif['credit'][0].":</span> ".$exif['credit'][1]."</li>";
  323.                 if($exif['shutter_speed']) $meta .= "<li class='exif-shutter_speed'><span>".$exif['shutter_speed'][0].":</span> ".$exif['shutter_speed'][1]."</li>";
  324.                 if($exif['iso']) $meta .= "<li class='exif-iso'><span>".$exif['iso'][0].":</span> ".$exif['iso'][1]."</li>";
  325.                 if($exif['aperture']) $meta .= "<li class='exif-aperture'><span>".$exif['aperture'][0].":</span> ".$exif['aperture'][1]."</li>";
  326.                 if($exif['focal_length']) $meta .= "<li class='exif-focal_length'><span>".$exif['focal_length'][0].":</span> ".$exif['focal_length'][1]."</li>";
  327.                
  328.             }
  329.            
  330.             if($meta)
  331.             {
  332.                 if(!$output) $output = " ";
  333.                 $meta = "<div class='hr'></div><ul>".$meta."</ul>";
  334.             }
  335.            
  336.             if($output)
  337.             {
  338.                 $output = "<div class='exif_data_tooltip'><div class='exif_data_inner_tooltip'>".$output.$meta."</div></div>";
  339.             }
  340.        
  341.         }
  342.  
  343.         return $output;
  344.        
  345.     }
  346.    
  347.    
  348.     function gallery_overlay()
  349.     {      
  350.         if($this->settings['overlay'] && $this->settings['overlay'] != 'none')
  351.         {
  352.             $this->settings['overlay'] = str_replace('{{AVIA_BASE_URL}}', AVIA_BASE_URL, $this->settings['overlay']);
  353.             $this->slideHtml .= "<div class='background_overlay' style='background-image:url(".$this->settings['overlay'].")'></div>";
  354.         }
  355.     }
  356.    
  357.    
  358.     function display()
  359.     {
  360.        
  361.         $this->gallery_overlay();
  362.         $this->create_HTML();
  363.         if($this->settings['gallery_controlls'] != 'hide')
  364.         {
  365.             $this->create_thumb_HTML();
  366.         }
  367.         echo $this->slideHtml;
  368.        
  369.     }
  370.  
  371. }
  372.  
  373. ######################################################################
  374. # avia_embed_images
  375. ######################################################################
  376.  
  377. class avia_embed_images extends avia_gallery_slider{
  378.  
  379.     function __construct($post_id = "")
  380.     {
  381.         global $avia_config;
  382.         if(isset($avia_config['block_gallery'])) return false;
  383.    
  384.         if(!$post_id)
  385.         {
  386.             $this->post_id = avia_get_the_ID();
  387.         }
  388.         else
  389.         {
  390.             $this->post_id = $post_id;
  391.         }
  392.        
  393.         //set tooltips
  394.         $settings['gallery_tooltips'] = avia_post_meta($this->post_id, 'gallery_tooltips');
  395.         if($settings['gallery_tooltips'] == '')
  396.         {
  397.             $settings['gallery_tooltips'] = avia_get_option('gallery_tooltips');
  398.             if(!$settings['gallery_tooltips']) $settings['gallery_tooltips'] ='all';
  399.         }
  400.  
  401.         //set autorotation
  402.         $settings['autorotate'] = avia_post_meta($this->post_id, 'inline_slideshow_duration');
  403.  
  404.         $this->settings = $settings;
  405.         //first try to get the post gallery
  406.         //$unqiue_id = avia_post_meta($this->post_id, 'gallery_image');
  407.         //$this->retrieve_post_images($unqiue_id, 'blog', 'url');
  408.         $this->retrieve_post_images($this->post_id, 'blog', 'url');
  409.         $this->create_HTML();
  410.         echo $this->slideHtml;
  411.     }
  412.    
  413.     //display the background gallery
  414.     function create_HTML()
  415.     {
  416.         global $avia_config;
  417.         $output = "";
  418.        
  419.         if(!empty($this->image_url_array[0]))
  420.         {  
  421.            
  422.             $extraClass = $extraClassContainer = "";
  423.             if(strpos($avia_config['layout'], 'thumbslider') !== false) $extraClass .=" slideshow";
  424.            
  425.             $autorotate = $this->settings['autorotate'];
  426.             if($autorotate != 'false' && $autorotate != '')
  427.             {
  428.                 $extraClassContainer .= ' autoslide_true';
  429.                 $extraClassContainer .= ' autoslidedelay__'. $this->settings['autorotate'];
  430.             }
  431.             else
  432.             {
  433.                 $extraClassContainer .= ' autoslide_false';
  434.             }
  435.            
  436.             $output .= "<div class='slideshow_container ".$avia_config['layout']." $extraClassContainer'>";
  437.             $output .= "<ul class='avia_embed_image_container ".$avia_config['layout']." $extraClass' >";
  438.             $counter = 1;
  439.             foreach($this->image_url_array as $key => $img)
  440.             {
  441.                 $exif = $title = $desc = "";
  442.                
  443.                 $exif_data = avia_exif_data($this->image_id_array[$key]);
  444.                 if(strpos($avia_config['layout'], 'thumbslider') === false)  $exif = $this->exif_container($this->image_id_array[$key], true, $exif_data);
  445.                 if(isset($exif_data['title'][1])) $title = strip_tags($exif_data['title'][1]);
  446.                 if(isset($exif_data['description'][1])) $desc = strip_tags($exif_data['description'][1]);
  447.                 $link = avia_image_by_id($this->image_id_array[$key], 'fullscreen', 'url');
  448.                
  449.                 if($title == "-") $title = $desc = "";
  450.                
  451.                 $output .= "<li class='avia_embed_image featured featured_container$counter imageslide'>
  452.                             <a href='".$link."' title='".$desc."'><img src='".$img."' title='$title' alt='$title'/></a> $exif</li>";
  453.                 $counter++;
  454.             }
  455.                
  456.             $output .= "</ul>";
  457.             $output .= "</div>";
  458.         }
  459.         $this->slideHtml .= $output;
  460.     }
  461.    
  462.    
  463.  
  464. }
  465.  
  466.  
  467.  
  468. ######################################################################
  469. # avia_embed_images
  470. ######################################################################
  471.  
  472. class avia_three_column extends avia_gallery_slider{
  473.  
  474.     function __construct($post_id = "")
  475.     {
  476.         global $avia_config;
  477.         if(isset($avia_config['block_gallery'])) return false;
  478.    
  479.         if(!$post_id)
  480.         {
  481.             $this->post_id = avia_get_the_ID();
  482.         }
  483.         else
  484.         {
  485.             $this->post_id = $post_id;
  486.         }
  487.        
  488.         //set tooltips
  489.         $settings['gallery_tooltips'] = avia_post_meta($this->post_id, 'gallery_tooltips');
  490.         if($settings['gallery_tooltips'] == '')
  491.         {
  492.             $settings['gallery_tooltips'] = avia_get_option('gallery_tooltips');
  493.             if(!$settings['gallery_tooltips']) $settings['gallery_tooltips'] ='all';
  494.         }
  495.  
  496.         //set autorotation
  497.         $settings['autorotate'] = avia_post_meta($this->post_id, 'inline_slideshow_duration');
  498.  
  499.         $this->settings = $settings;
  500.         //first try to get the post gallery
  501.         //$unqiue_id = avia_post_meta($this->post_id, 'gallery_image');
  502.         //$this->retrieve_post_images($unqiue_id, 'portfolio', 'url');
  503.         $this->retrieve_post_images($this->post_id, 'portfolio', 'url');
  504.         $this->create_HTML();
  505.         echo $this->slideHtml;
  506.     }
  507.    
  508.     //display the background gallery
  509.     function create_HTML()
  510.     {
  511.         global $avia_config;
  512.         $output = "";
  513.        
  514.         if(!empty($this->image_url_array[0]))
  515.         {  
  516.            
  517.             $extraClass = $extraClassContainer = "";
  518.             if(strpos($avia_config['layout'], 'thumbslider') !== false) $extraClass .=" slideshow";
  519.            
  520.             $autorotate = $this->settings['autorotate'];
  521.             if($autorotate != 'false' && $autorotate != '')
  522.             {
  523.                 $extraClassContainer .= ' autoslide_true';
  524.                 $extraClassContainer .= ' autoslidedelay__'. $this->settings['autorotate'];
  525.             }
  526.             else
  527.             {
  528.                 $extraClassContainer .= ' autoslide_false';
  529.             }
  530.            
  531.             $output .= "<div class='slideshow_container ".$avia_config['layout']." $extraClassContainer'>";
  532.             $loop_counter = 1;
  533.             $extraClass = 'first';
  534.             $columns = 3;
  535.             foreach($this->image_url_array as $key => $img)
  536.             {
  537.                 $exif = $title = $desc = "";
  538.                
  539.                 $exif_data = avia_exif_data($this->image_id_array[$key]);
  540.                 if(strpos($avia_config['layout'], 'thumbslider') === false)  $exif = $this->exif_container($this->image_id_array[$key], true, $exif_data);
  541.                 if(isset($exif_data['title'][1])) $title = strip_tags($exif_data['title'][1]);
  542.                 if(isset($exif_data['description'][1])) $desc = strip_tags($exif_data['description'][1]);
  543.                 $link = avia_image_by_id($this->image_id_array[$key], 'fullscreen', 'url');
  544.                
  545.                 if($title == "-") $title = $desc = "";
  546.                
  547.                 $output .= "<div class='avia_embed_image avia_3_column_gallery $extraClass'><a href='".$link."' title='".$desc."'><img src='".$img."' title='$title' alt='$title'/></a> $exif</div>";
  548.                
  549.                 $loop_counter++;
  550.                 $extraClass = "";
  551.                
  552.                 if($loop_counter > $columns)
  553.                 {
  554.                     $loop_counter = 1;
  555.                     $extraClass = 'first';
  556.                 }
  557.                
  558.                
  559.             }
  560.                
  561.             $output .= "</div>";
  562.            
  563.            
  564.         }
  565.         $this->slideHtml .= $output;
  566.     }
  567.    
  568.    
  569.  
  570. }
  571.  
  572.  
  573.  
  574. class masonry_gallery
  575. {
  576.     var $id;
  577.     var $imgSize;
  578.     var $image_array;
  579.     var $settings;
  580.     var $itemcount;
  581.     var $slicecount;
  582.    
  583.     function __construct($size = "masonry")
  584.     {
  585.         global $avia_config;
  586.         if(isset($avia_config['block_gallery'])) return false;
  587.    
  588.         $this->id = avia_get_the_ID();
  589.    
  590.         //set tooltips
  591.         $settings['gallery_tooltips'] = avia_post_meta($this->id, 'gallery_tooltips');
  592.         if($settings['gallery_tooltips'] == '')
  593.         {
  594.             $settings['gallery_tooltips'] = avia_get_option('gallery_tooltips');
  595.             if(!$settings['gallery_tooltips']) $settings['gallery_tooltips'] ='all';
  596.         }
  597.    
  598.         $this->settings = $settings;
  599.        
  600.         $this->imgSize = $size;
  601.         $this->retrieve_post_images();
  602.     }
  603.     /*
  604.  
  605.     //gets the hidden post of type avia_framework_post that is used to store uploads in a separate gallery
  606.     function retrieve_post_images()
  607.     {  
  608.         global $avia_config;
  609.         $unqiue_id = avia_post_meta($this->id, 'gallery_image');
  610.         $attachment_holder = avia_get_post_by_title( "avia_smart-gallery-of-post-".$unqiue_id);
  611.        
  612.         if(empty($attachment_holder['ID'])) return;
  613.        
  614.         $attachments = get_children(array('post_parent' => $attachment_holder['ID'],
  615.                         'post_status' => 'inherit',
  616.                         'post_type' => 'attachment',
  617.                         'post_mime_type' => 'image',
  618.                         'order' => 'ASC',
  619.                         'orderby' => 'menu_order ID'));
  620.  
  621.  
  622.         foreach($attachments as $key => $attachment)
  623.         {
  624.             $this->image_array['url'][]  = avia_image_by_id($attachment->ID, $avia_config['imgSize'][$this->imgSize], 'url');
  625.             $this->image_array['link'][] = avia_image_by_id($attachment->ID, 'fullsize','url');
  626.             $this->image_array['id'][]   = $attachment->ID;
  627.         }
  628.        
  629.         $this->itemcount = count($this->image_array['id']);
  630.     }
  631. */
  632.    
  633.         //gets the hidden post of type avia_framework_post that is used to store uploads in a separate gallery
  634.     function retrieve_post_images()
  635.     {  
  636.         global $avia_config;
  637.         $attachments = avia_post_meta($this->id, 'slideshow');
  638.        
  639.         if(!$attachments)
  640.         {
  641.             $unqiue_id = avia_post_meta($this->id, 'gallery_image');
  642.             $attachment_holder = avia_get_post_by_title( "avia_smart-gallery-of-post-".$unqiue_id);
  643.            
  644.             if(empty($attachment_holder['ID'])) return;
  645.             $attachments = get_children(array('post_parent' => $attachment_holder['ID'],
  646.                         'post_status' => 'inherit',
  647.                         'post_type' => 'attachment',
  648.                         'post_mime_type' => 'image',
  649.                         'order' => 'ASC',
  650.                         'orderby' => 'menu_order ID'));
  651.         }
  652.        
  653.         if(!empty($attachments))
  654.         {
  655.             foreach($attachments as $key => $attachment)
  656.             {
  657.                 if(is_array($attachment))
  658.                 {
  659.                     $att_id = $attachment['slideshow_image'];
  660.                     $this->image_meta_content[$att_id] = $attachment;
  661.                 }
  662.                 else
  663.                 {
  664.                     $att_id = $attachment->ID;
  665.                 }
  666.            
  667.            
  668.                 $this->image_array['url'][]  = avia_image_by_id($att_id, $avia_config['imgSize'][$this->imgSize], 'url');
  669.                 $this->image_array['link'][] = avia_image_by_id($att_id, 'fullsize','url');
  670.                 $this->image_array['id'][]   = $att_id;
  671.             }
  672.         }
  673.        
  674.        
  675.         $this->itemcount = count($this->image_array['id']);
  676.     }
  677.    
  678.    
  679.    
  680.    
  681.    
  682.    
  683.    
  684.    
  685.    
  686.    
  687.    
  688.     function exif_container($id, $showmeta = true, $exif_data)
  689.     {
  690.         $output = "";
  691.        
  692.         if($this->settings['gallery_tooltips'] == 'all' || $this->settings['gallery_tooltips'] == 'title')
  693.         {
  694.            
  695.             if($this->settings['gallery_tooltips'] == 'title') $showmeta = false;
  696.             $exif = $exif_data;
  697.             $meta = "";
  698.            
  699.             if(isset($this->image_meta_content[$id]))
  700.             {
  701.                 $exif['title'][1] = $this->image_meta_content[$id]['slideshow_caption_title'];
  702.                 $exif['description'][1] = $this->image_meta_content[$id]['slideshow_caption'];
  703.                
  704.                 if(empty($exif['title'][1])) $exif['title'] = "";
  705.                 if(empty($exif['description'][1])) $exif['description'] = "";
  706.             }
  707.            
  708.             if(!empty($exif['title']) && $exif['title'][1] == "-"){$exif['title'] = ""; $exif['description'] = ""; $showmeta = false;}
  709.            
  710.             if($exif['title'] || $exif['description'])
  711.             {
  712.                 if($exif['title']) $output .= "<strong>".$exif['title'][1]."</strong>";
  713.                 if($exif['description']) $output .= "<div class='description'>".$exif['description'][1]."</div>";
  714.             }
  715.            
  716.             if($showmeta)
  717.             {
  718.                 if($exif['camera']) $meta .= "<li class='exif-camera'><span>".$exif['camera'][0].":</span> ".$exif['camera'][1]."</li>";
  719.                 if($exif['created_timestamp']) $meta .= "<li class='exif-created_timestamp'><span>".$exif['created_timestamp'][0].":</span> ".$exif['created_timestamp'][1]."</li>";
  720.                 if($exif['copyright']) $meta .= "<li class='exif-copyright'><span>".$exif['copyright'][0].":</span> ".$exif['copyright'][1]."</li>";
  721.                 if($exif['credit']) $meta .= "<li class='exif-credit'><span>".$exif['credit'][0].":</span> ".$exif['credit'][1]."</li>";
  722.                 if($exif['shutter_speed']) $meta .= "<li class='exif-shutter_speed'><span>".$exif['shutter_speed'][0].":</span> ".$exif['shutter_speed'][1]."</li>";
  723.                 if($exif['iso']) $meta .= "<li class='exif-iso'><span>".$exif['iso'][0].":</span> ".$exif['iso'][1]."</li>";
  724.                 if($exif['aperture']) $meta .= "<li class='exif-aperture'><span>".$exif['aperture'][0].":</span> ".$exif['aperture'][1]."</li>";
  725.                 if($exif['focal_length']) $meta .= "<li class='exif-focal_length'><span>".$exif['focal_length'][0].":</span> ".$exif['focal_length'][1]."</li>";
  726.                
  727.             }
  728.            
  729.             if($meta)
  730.             {  
  731.                 if(!$output) $output = " ";
  732.                 $meta = "<div class='hr'></div><ul>".$meta."</ul>";
  733.             }
  734.            
  735.             if($output)
  736.             {
  737.                 $output = "<div class='exif_data'><div class='exif_data_inner'>".$output.$meta."</div></div>";
  738.             }
  739.        
  740.         }
  741.  
  742.         return $output;
  743.        
  744.     }
  745.    
  746.     function pagecount()
  747.     {
  748.         if(!$this->slicecount || !$this->itemcount) return false;
  749.        
  750.         $pages = ceil($this->itemcount/$this->slicecount);
  751.         return $pages;
  752.     }
  753.    
  754.    
  755.    
  756.     function display($itemcount=10)
  757.     {
  758.         global $paged;
  759.        
  760.         if(get_query_var('paged')) {
  761.              $paged = get_query_var('paged');
  762.         } elseif(get_query_var('page')) {
  763.              $paged = get_query_var('page');
  764.         } else {
  765.              $paged = 1;
  766.         }
  767.        
  768.         $offset = $itemcount * ($paged - 1);
  769.        
  770.         if(!is_array($this->image_array['url'])) return;
  771.        
  772.         $this->image_array['url'] = array_slice($this->image_array['url'], $offset, $itemcount);
  773.         $this->image_array['link'] = array_slice($this->image_array['link'], $offset, $itemcount);
  774.         $this->image_array['id'] = array_slice($this->image_array['id'], $offset, $itemcount);
  775.         $this->slicecount = $itemcount;
  776.        
  777.         $output = "";
  778.        
  779.         foreach($this->image_array['url'] as $key => $attachment)
  780.         {
  781.             $exif_data = avia_exif_data($this->image_array['id'][$key]);
  782.             $exif = $this->exif_container($this->image_array['id'][$key], true, $exif_data);
  783.             $title = $desc = "";
  784.             if(isset($exif_data['title'][1])) $title = strip_tags($exif_data['title'][1]);
  785.             if(isset($exif_data['description'][1])) $desc = strip_tags($exif_data['description'][1]);
  786.        
  787.             if($title == "-") $title = $desc = "";
  788.        
  789.             $output .= "<div class='masonry-item'>";
  790.             $output .= "<div class='masonry-image'><a href='".$this->image_array['link'][$key]."' title='".$desc."'><img src='".$this->image_array['url'][$key]."' title='$title' alt='$title'/></a></div>";
  791.            
  792.             if($exif)
  793.             {
  794.                 $output .= "<div class='masonry-content'>";
  795.                 $output .=  $exif;         
  796.                 $output .= "</div>";
  797.             }
  798.             $output .= "</div>";
  799.  
  800.         }
  801.        
  802.         return $output;
  803.     }
  804.    
  805. }
  806.  
  807.  
  808.  
  809.  
  810.  
  811.  
  812.  
  813.  
  814. /*helper function for exif data*/
  815.  
  816.  
  817. function avia_exif_data($attachment_id = "")
  818. {  
  819.     $exif = array('title'=>'', 'description' => '', 'aperture'=>'', 'credit'=>'', 'camera'=>'', 'copyright'=>'', 'focal_length'=>'', 'iso'=>'','shutter_speed'=>'','created_timestamp'=>'' );
  820.     if(!$attachment_id) return $exif;
  821.    
  822.     $post = get_post($attachment_id);
  823.     $meta = wp_get_attachment_metadata($attachment_id, FALSE);
  824.     $meta = $meta['image_meta'];
  825.    
  826.  
  827.    
  828.     if(!empty($meta['aperture']))           {   $exif['aperture']    = array(__('Aperture','avia_framework'), $meta['aperture']);       }
  829.     if(!empty($meta['credit']))             {   $exif['credit']      = array(__('Credit','avia_framework'), str_replace('©','&copy;', $meta['credit']));     }
  830.     if(!empty($meta['camera']))             {   $exif['camera']      = array(__('Camera','avia_framework'), $meta['camera']);       }
  831.     if(!empty($meta['copyright']))          {   $exif['copyright']   = array(__('Copyright','avia_framework'), str_replace('©','&copy;', $meta['copyright']));       }
  832.     if(!empty($meta['focal_length']))       {   $exif['focal_length']= array(__('Focal Length','avia_framework'), $meta['focal_length']);       }
  833.     if(!empty($meta['iso']))                {   $exif['iso']         = array(__('ISO','avia_framework'), $meta['iso']);     }
  834.     if(!empty($meta['shutter_speed']))      {   $exif['shutter_speed']       = array(__('Shutter','avia_framework'), $meta['shutter_speed']);       }
  835.     if(!empty($meta['created_timestamp']))  {   $exif['created_timestamp']  = array(__('Created','avia_framework'), date( "F d, Y - H:i", $meta['created_timestamp']));     }
  836.     if(!empty($post->post_title))           {   $exif['title']       = array(__('Title','avia_framework'), $post->post_title);          }
  837.     if(!empty($post->post_content))         {   $exif['description'] = array(__('Description','avia_framework'), $post->post_content);  }
  838.     if(!empty($post->post_excerpt) &&
  839.         empty($post->post_content))         {   $exif['description'] = array(__('Description','avia_framework'), $post->post_content);  }
  840.  
  841.     return $exif;
  842. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement