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 avia_gallery_slider($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.  
  29.             $settings['gallery_layout'] = "bg_gallery";
  30.             $settings['autorotate'] = avia_get_option('slideshow_duration');
  31.             $settings['overlay'] = avia_get_option('gallery_overlay');
  32.             $settings['gallery_tooltips'] = avia_get_option('gallery_tooltips');
  33.             $settings['gallery_controlls'] = 'hide';
  34.             $settings['transition'] = avia_get_option('gallery_transition');
  35.             $settings['cropping'] = avia_get_option('gallery_cropping');
  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.             if(!avia_post_meta($this->post_id, 'bg_gallery_use_default') || $settings['gallery_layout'] == 'bg_gallery')
  97.             {
  98.                 if(!post_password_required())
  99.                     {
  100.                     //get the unique id so we know which gallery to retrieve
  101.                     $unqiue_id = avia_post_meta($this->post_id, 'gallery_image');
  102.  
  103.                     $this->retrieve_post_images($unqiue_id);
  104.                     }
  105.                 }
  106.         }
  107.  
  108.  
  109.  
  110.         //then try to retrieve the fallback gallery
  111.         if(empty($this->image_url_array[0])) $this->retrieve_post_images();
  112.  
  113.         //if we got no images use the default image
  114.         if(empty($this->image_url_array[0]) && avia_get_option('bg_image_repeat') == 'fullscreen') $this->image_url_array[0] = avia_get_option('bg_image');
  115.  
  116.  
  117.         //if the user cant controll the bg library and autorotation is deactivated we only need a single background image
  118.         if($settings['gallery_controlls'] == 'hide' && $settings['autorotate'] == 'false')
  119.         {
  120.             if(!empty($this->image_url_array[1]))
  121.             {
  122.                 $temp = $this->image_url_array[0];
  123.                 unset($this->image_url_array);
  124.                 $this->image_url_array[0] = $temp;
  125.             }
  126.         }
  127.  
  128.         $this->settings = $settings;
  129.     }
  130.  
  131.     //gets the hidden post of type avia_framework_post that is used to store uploads in a separate gallery
  132.     function retrieve_post_images($id = "", $size = "fullsize", $returnvalue = 'url')
  133.     {
  134.         global $avia_config;
  135.  
  136.         if(!$id)
  137.         {
  138.             $attachment_holder = avia_get_post_by_title( "avia_smart-default-gallery");
  139.         }
  140.         else
  141.         {
  142.             $attachment_holder = avia_get_post_by_title( "avia_smart-gallery-of-post-".$id);
  143.         }
  144.  
  145.             if(empty($attachment_holder['ID'])) return;
  146.  
  147.         $attachments = get_children(array('post_parent' => $attachment_holder['ID'],
  148.                         'post_status' => 'inherit',
  149.                         'post_type' => 'attachment',
  150.                         'post_mime_type' => 'image',
  151.                         'order' => 'ASC',
  152.                         'orderby' => 'menu_order ID'));
  153.  
  154.  
  155.         foreach($attachments as $key => $attachment)
  156.         {
  157.             $this->image_url_array[] = avia_image_by_id($attachment->ID, $avia_config['imgSize'][$size], $returnvalue);
  158.             $this->image_thumb_url_array[] = avia_image_by_id($attachment->ID, $avia_config['imgSize']['widget'], 'url');
  159.             $this->image_id_array[] = $attachment->ID;
  160.         }
  161.     }
  162.  
  163.  
  164.     //display the background gallery
  165.     function create_HTML()
  166.     {
  167.         $output = "";
  168.  
  169.         if(!empty($this->image_url_array[0]))
  170.         {
  171.             $controlls  = $this->settings['gallery_controlls'];
  172.             $autorotate = $this->settings['autorotate'];
  173.             $transition = $this->settings['transition'];
  174.             $cropping   = $this->settings['cropping'];
  175.  
  176.             $data = " data-autorotation ='false' ";
  177.  
  178.             if($autorotate != 'false' && $autorotate != '')
  179.             {
  180.                 $data  = " data-autorotationspeed ='$autorotate' ";
  181.                 $data .= " data-autorotation ='true' ";
  182.             }
  183.  
  184.             if($controlls == 'hide')
  185.             {
  186.                 $data .= " data-appendcontrolls='false'";
  187.             }
  188.  
  189.             if($cropping != "" && $cropping != "cropping")
  190.             {
  191.                 $data .= " data-cropping='false'";
  192.             }
  193.  
  194.             $data .= " data-hide='".__('hide sidebar &amp; content','avia_framework')."'";
  195.             $data .= " data-imagecounter='".__('Image -X- from -Y-','avia_framework')."'";
  196.             $data .= " data-transition ='$transition' ";
  197.  
  198.  
  199.             $output .= "<ul class='avia_fullscreen_slider $cropping' $data >";
  200.  
  201.             foreach($this->image_url_array as $url)
  202.             {
  203.                 $output .= "<li data-image='$url'></li>";
  204.             }
  205.  
  206.             $output .= "</ul><noscript><div id='fallbackImage' style='background-image:url($url)'></div></noscript>";
  207.         }
  208.         $this->slideHtml .= $output;
  209.     }
  210.  
  211.     function create_thumb_HTML()
  212.     {
  213.         $first = "active_thumb";
  214.         $output = "";
  215.         if(!empty($this->image_thumb_url_array[1]))
  216.         {
  217.  
  218.             $output .= "<div class='avia_fullscreen_slider_thumbs'>";
  219.             $output .= "<div class='border-transparent border-transparent-right'></div>";
  220.             $output .= "<div class='border-transparent border-transparent-top'></div>";
  221.             $output .= "<a class='slide_thumbnails no_scroll' href='#'></a>";
  222.             $output .= "<div class='avia_fullscreen_slider_thumbs_inner'>";
  223.             $output .= "<div class='avia_fullscreen_slider_thumbs_outer_slide'>";
  224.             $output .= "<div class='avia_fullscreen_slider_thumbs_inner_slide'>";
  225.  
  226.             foreach($this->image_thumb_url_array as $key => $img)
  227.             {
  228.                 $exif = $this->exif_container($this->image_id_array[$key], true);
  229.                 $output .= "<div class='fullscreen_thumb $first'><img src='$img' title='' alt='' /> $exif</div>";
  230.                 $first = "";
  231.             }
  232.  
  233.             $output .= "</div></div></div></div>";
  234.         }
  235.         $this->slideHtml .= $output;
  236.     }
  237.  
  238.     function exif_container($id, $showmeta = true)
  239.     {
  240.         $output = "";
  241.  
  242.         if($this->settings['gallery_tooltips'] == 'all' || $this->settings['gallery_tooltips'] == 'title')
  243.         {
  244.  
  245.             if($this->settings['gallery_tooltips'] == 'title') $showmeta = false;
  246.             $exif = avia_exif_data($id);
  247.             $meta = "";
  248.  
  249.             if($exif['title'][1] == "-"){$exif['title'] = ""; $exif['description'] = ""; $showmeta = false;}
  250.  
  251.             if($exif['title'] || $exif['description'])
  252.             {
  253.                 if($exif['title']) $output .= "<strong>".$exif['title'][1]."</strong>";
  254.                 if($exif['description']) $output .= "<div class='description'>".$exif['description'][1]."</div>";
  255.             }
  256.  
  257.             if($showmeta)
  258.             {
  259.                 if($exif['camera']) $meta .= "<li class='exif-camera'><span>".$exif['camera'][0].":</span> ".$exif['camera'][1]."</li>";
  260.                 if($exif['created_timestamp']) $meta .= "<li class='exif-created_timestamp'><span>".$exif['created_timestamp'][0].":</span> ".$exif['created_timestamp'][1]."</li>";
  261.                 if($exif['copyright']) $meta .= "<li class='exif-copyright'><span>".$exif['copyright'][0].":</span> ".$exif['copyright'][1]."</li>";
  262.                 if($exif['credit']) $meta .= "<li class='exif-credit'><span>".$exif['credit'][0].":</span> ".$exif['credit'][1]."</li>";
  263.                 if($exif['shutter_speed']) $meta .= "<li class='exif-shutter_speed'><span>".$exif['shutter_speed'][0].":</span> ".$exif['shutter_speed'][1]."</li>";
  264.                 if($exif['iso']) $meta .= "<li class='exif-iso'><span>".$exif['iso'][0].":</span> ".$exif['iso'][1]."</li>";
  265.                 if($exif['aperture']) $meta .= "<li class='exif-aperture'><span>".$exif['aperture'][0].":</span> ".$exif['aperture'][1]."</li>";
  266.                 if($exif['focal_length']) $meta .= "<li class='exif-focal_length'><span>".$exif['focal_length'][0].":</span> ".$exif['focal_length'][1]."</li>";
  267.  
  268.             }
  269.  
  270.             if($meta)
  271.             {
  272.                 $meta = "<div class='hr'></div><ul>".$meta."</ul>";
  273.             }
  274.  
  275.             if($output)
  276.             {
  277.                 $output = "<div class='exif_data_tooltip'><div class='exif_data_inner_tooltip'>".$output.$meta."</div></div>";
  278.             }
  279.  
  280.         }
  281.  
  282.         return $output;
  283.  
  284.     }
  285.  
  286.  
  287.     function gallery_overlay()
  288.     {
  289.         if($this->settings['overlay'] && $this->settings['overlay'] != 'none')
  290.         {
  291.             $this->slideHtml .= "<div class='background_overlay' style='background-image:url(".$this->settings['overlay'].")'></div>";
  292.         }
  293.     }
  294.  
  295.  
  296.     function display()
  297.     {
  298.  
  299.         $this->gallery_overlay();
  300.         $this->create_HTML();
  301.         if($this->settings['gallery_controlls'] != 'hide')
  302.         {
  303.             $this->create_thumb_HTML();
  304.         }
  305.         echo $this->slideHtml;
  306.  
  307.     }
  308.  
  309. }
  310.  
  311. ######################################################################
  312. # avia_embed_images
  313. ######################################################################
  314.  
  315. class avia_embed_images extends avia_gallery_slider{
  316.  
  317.     function avia_embed_images($post_id = "")
  318.     {
  319.         global $avia_config;
  320.         if(isset($avia_config['block_gallery'])) return false;
  321.  
  322.         if(!$post_id)
  323.         {
  324.             $this->post_id = avia_get_the_ID();
  325.         }
  326.         else
  327.         {
  328.             $this->post_id = $post_id;
  329.         }
  330.  
  331.         //set tooltips
  332.         $settings['gallery_tooltips'] = avia_post_meta($this->post_id, 'gallery_tooltips');
  333.         if($settings['gallery_tooltips'] == '')
  334.         {
  335.             $settings['gallery_tooltips'] = avia_get_option('gallery_tooltips');
  336.             if(!$settings['gallery_tooltips']) $settings['gallery_tooltips'] ='all';
  337.         }
  338.  
  339.         //set autorotation
  340.         $settings['autorotate'] = avia_post_meta($this->post_id, 'inline_slideshow_duration');
  341.  
  342.         $this->settings = $settings;
  343.         //first try to get the post gallery
  344.         $unqiue_id = avia_post_meta($this->post_id, 'gallery_image');
  345.         $this->retrieve_post_images($unqiue_id, 'blog', 'url');
  346.         $this->create_HTML();
  347.         echo $this->slideHtml;
  348.     }
  349.  
  350.     //display the background gallery
  351.     function create_HTML()
  352.     {
  353.         global $avia_config;
  354.         $output = "";
  355.  
  356.         if(!empty($this->image_url_array[0]))
  357.         {
  358.  
  359.             $extraClass = $extraClassContainer = "";
  360.             if(strpos($avia_config['layout'], 'thumbslider') !== false) $extraClass .=" slideshow";
  361.  
  362.             $autorotate = $this->settings['autorotate'];
  363.             if($autorotate != 'false' && $autorotate != '')
  364.             {
  365.                 $extraClassContainer .= ' autoslide_true';
  366.                 $extraClassContainer .= ' autoslidedelay__'. $this->settings['autorotate'];
  367.             }
  368.             else
  369.             {
  370.                 $extraClassContainer .= ' autoslide_false';
  371.             }
  372.  
  373.             $output .= "<div class='slideshow_container ".$avia_config['layout']." $extraClassContainer'>";
  374.             $output .= "<ul class='avia_embed_image_container ".$avia_config['layout']." $extraClass' >";
  375.             $counter = 1;
  376.             foreach($this->image_url_array as $key => $img)
  377.             {
  378.                 $exif = $title = $desc = "";
  379.  
  380.                 $exif_data = avia_exif_data($this->image_id_array[$key]);
  381.                 if(strpos($avia_config['layout'], 'thumbslider') === false)  $exif = $this->exif_container($this->image_id_array[$key], true, $exif_data);
  382.                 if(isset($exif_data['title'][1])) $title = strip_tags($exif_data['title'][1]);
  383.                 if(isset($exif_data['description'][1])) $desc = strip_tags($exif_data['description'][1]);
  384.                 $link = avia_image_by_id($this->image_id_array[$key], 'fullscreen', 'url');
  385.  
  386.                 if($title == "-") $title = $desc = "";
  387.  
  388.                 $output .= "<li class='avia_embed_image featured featured_container$counter imageslide'>
  389.                             <a href='".$link."' title='".$desc."'><img src='".$img."' title='$title' alt='$title'/></a> $exif</li>";
  390.                 $counter++;
  391.             }
  392.  
  393.             $output .= "</ul>";
  394.             $output .= "</div>";
  395.         }
  396.         $this->slideHtml .= $output;
  397.     }
  398.  
  399.  
  400.  
  401. }
  402.  
  403.  
  404.  
  405. ######################################################################
  406. # avia_embed_images
  407. ######################################################################
  408.  
  409. class avia_three_column extends avia_gallery_slider{
  410.  
  411.     function avia_three_column($post_id = "")
  412.     {
  413.         global $avia_config;
  414.         if(isset($avia_config['block_gallery'])) return false;
  415.  
  416.         if(!$post_id)
  417.         {
  418.             $this->post_id = avia_get_the_ID();
  419.         }
  420.         else
  421.         {
  422.             $this->post_id = $post_id;
  423.         }
  424.  
  425.         //set tooltips
  426.         $settings['gallery_tooltips'] = avia_post_meta($this->post_id, 'gallery_tooltips');
  427.         if($settings['gallery_tooltips'] == '')
  428.         {
  429.             $settings['gallery_tooltips'] = avia_get_option('gallery_tooltips');
  430.             if(!$settings['gallery_tooltips']) $settings['gallery_tooltips'] ='all';
  431.         }
  432.  
  433.         //set autorotation
  434.         $settings['autorotate'] = avia_post_meta($this->post_id, 'inline_slideshow_duration');
  435.  
  436.         $this->settings = $settings;
  437.         //first try to get the post gallery
  438.         $unqiue_id = avia_post_meta($this->post_id, 'gallery_image');
  439.         $this->retrieve_post_images($unqiue_id, 'portfolio', 'url');
  440.         $this->create_HTML();
  441.         echo $this->slideHtml;
  442.     }
  443.  
  444.     //display the background gallery
  445.     function create_HTML()
  446.     {
  447.         global $avia_config;
  448.         $output = "";
  449.  
  450.         if(!empty($this->image_url_array[0]))
  451.         {
  452.  
  453.             $extraClass = $extraClassContainer = "";
  454.             if(strpos($avia_config['layout'], 'thumbslider') !== false) $extraClass .=" slideshow";
  455.  
  456.             $autorotate = $this->settings['autorotate'];
  457.             if($autorotate != 'false' && $autorotate != '')
  458.             {
  459.                 $extraClassContainer .= ' autoslide_true';
  460.                 $extraClassContainer .= ' autoslidedelay__'. $this->settings['autorotate'];
  461.             }
  462.             else
  463.             {
  464.                 $extraClassContainer .= ' autoslide_false';
  465.             }
  466.  
  467.             $output .= "<div class='slideshow_container ".$avia_config['layout']." $extraClassContainer'>";
  468.             $loop_counter = 1;
  469.             $extraClass = 'first';
  470.             $columns = 3;
  471.             foreach($this->image_url_array as $key => $img)
  472.             {
  473.                 $exif = $title = $desc = "";
  474.  
  475.                 $exif_data = avia_exif_data($this->image_id_array[$key]);
  476.                 if(strpos($avia_config['layout'], 'thumbslider') === false)  $exif = $this->exif_container($this->image_id_array[$key], true, $exif_data);
  477.                 if(isset($exif_data['title'][1])) $title = strip_tags($exif_data['title'][1]);
  478.                 if(isset($exif_data['description'][1])) $desc = strip_tags($exif_data['description'][1]);
  479.                 $link = avia_image_by_id($this->image_id_array[$key], 'fullscreen', 'url');
  480.  
  481.                 if($title == "-") $title = $desc = "";
  482.  
  483.                 $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>";
  484.  
  485.                 $loop_counter++;
  486.                 $extraClass = "";
  487.  
  488.                 if($loop_counter > $columns)
  489.                 {
  490.                     $loop_counter = 1;
  491.                     $extraClass = 'first';
  492.                 }
  493.  
  494.  
  495.             }
  496.  
  497.             $output .= "</div>";
  498.  
  499.  
  500.         }
  501.         $this->slideHtml .= $output;
  502.     }
  503.  
  504.  
  505.  
  506. }
  507.  
  508.  
  509.  
  510. class masonry_gallery
  511. {
  512.     var $id;
  513.     var $imgSize;
  514.     var $image_array;
  515.     var $settings;
  516.     var $itemcount;
  517.     var $slicecount;
  518.  
  519.     function masonry_gallery($size = "masonry")
  520.     {
  521.         global $avia_config;
  522.         if(isset($avia_config['block_gallery'])) return false;
  523.  
  524.         $this->id = avia_get_the_ID();
  525.  
  526.         //set tooltips
  527.         $settings['gallery_tooltips'] = avia_post_meta($this->id, 'gallery_tooltips');
  528.         if($settings['gallery_tooltips'] == '')
  529.         {
  530.             $settings['gallery_tooltips'] = avia_get_option('gallery_tooltips');
  531.             if(!$settings['gallery_tooltips']) $settings['gallery_tooltips'] ='all';
  532.         }
  533.  
  534.         $this->settings = $settings;
  535.  
  536.         $this->imgSize = $size;
  537.         $this->retrieve_post_images();
  538.     }
  539.  
  540.     //gets the hidden post of type avia_framework_post that is used to store uploads in a separate gallery
  541.     function retrieve_post_images()
  542.     {
  543.         global $avia_config;
  544.         $unqiue_id = avia_post_meta($this->id, 'gallery_image');
  545.         $attachment_holder = avia_get_post_by_title( "avia_smart-gallery-of-post-".$unqiue_id);
  546.  
  547.         if(empty($attachment_holder['ID'])) return;
  548.  
  549.         $attachments = get_children(array('post_parent' => $attachment_holder['ID'],
  550.                         'post_status' => 'inherit',
  551.                         'post_type' => 'attachment',
  552.                         'post_mime_type' => 'image',
  553.                         'order' => 'ASC',
  554.                         'orderby' => 'menu_order ID'));
  555.  
  556.  
  557.         foreach($attachments as $key => $attachment)
  558.         {
  559.  
  560.  
  561.             $this->image_array['url'][]  = avia_image_by_id($attachment->ID, $avia_config['imgSize'][$this->imgSize], 'url');
  562.  
  563.             $this->image_array['link'][] = avia_image_by_id($attachment->ID, 'fullsize','url');
  564.  
  565.             $this->image_array['link'][] = avia_image_by_id($attachment->ID, 'fullsize','url');
  566.             $this->image_array['id'][]   = $attachment->ID;
  567.         }
  568.  
  569.         $this->itemcount = count($this->image_array['id']);
  570.     }
  571.  
  572.  
  573.     function exif_container($id, $showmeta = true, $exif_data)
  574.     {
  575.         $output = "";
  576.  
  577.         if($this->settings['gallery_tooltips'] == 'all' || $this->settings['gallery_tooltips'] == 'title')
  578.         {
  579.  
  580.             if($this->settings['gallery_tooltips'] == 'title') $showmeta = false;
  581.             $exif = $exif_data;
  582.             $meta = "";
  583.  
  584.             if($exif['title'][1] == "-"){$exif['title'] = ""; $exif['description'] = ""; $showmeta = false;}
  585.  
  586.             if($exif['title'] || $exif['description'])
  587.             {
  588.                 if($exif['title']) $output .= "<strong>".$exif['title'][1]."</strong>";
  589.                 if($exif['description']) $output .= "<div class='description'>".$exif['description'][1]."</div>";
  590.             }
  591.  
  592.             if($showmeta)
  593.             {
  594.                 if($exif['camera']) $meta .= "<li class='exif-camera'><span>".$exif['camera'][0].":</span> ".$exif['camera'][1]."</li>";
  595.                 if($exif['created_timestamp']) $meta .= "<li class='exif-created_timestamp'><span>".$exif['created_timestamp'][0].":</span> ".$exif['created_timestamp'][1]."</li>";
  596.                 if($exif['copyright']) $meta .= "<li class='exif-copyright'><span>".$exif['copyright'][0].":</span> ".$exif['copyright'][1]."</li>";
  597.                 if($exif['credit']) $meta .= "<li class='exif-credit'><span>".$exif['credit'][0].":</span> ".$exif['credit'][1]."</li>";
  598.                 if($exif['shutter_speed']) $meta .= "<li class='exif-shutter_speed'><span>".$exif['shutter_speed'][0].":</span> ".$exif['shutter_speed'][1]."</li>";
  599.                 if($exif['iso']) $meta .= "<li class='exif-iso'><span>".$exif['iso'][0].":</span> ".$exif['iso'][1]."</li>";
  600.                 if($exif['aperture']) $meta .= "<li class='exif-aperture'><span>".$exif['aperture'][0].":</span> ".$exif['aperture'][1]."</li>";
  601.                 if($exif['focal_length']) $meta .= "<li class='exif-focal_length'><span>".$exif['focal_length'][0].":</span> ".$exif['focal_length'][1]."</li>";
  602.             }
  603.  
  604.             if($meta)
  605.             {
  606.                 $meta = "<div class='hr'></div><ul>".$meta."</ul>";
  607.             }
  608.  
  609.  
  610.             if($output)
  611.             {
  612.                 $output = "<div class='exif_data'><div class='exif_data_inner'>".$output.$meta.$pinit."</div></div>";
  613.             }
  614.  
  615.         }
  616.  
  617.         return $output;
  618.  
  619.     }
  620.  
  621.     function pagecount()
  622.     {
  623.         if(!$this->slicecount || !$this->itemcount) return false;
  624.  
  625.         $pages = ceil($this->itemcount/$this->slicecount);
  626.         return $pages;
  627.     }
  628.  
  629.  
  630.  
  631.     function display($itemcount=10)
  632.     {
  633.         global $paged;
  634.  
  635.         if(get_query_var('paged')) {
  636.              $paged = get_query_var('paged');
  637.         } elseif(get_query_var('page')) {
  638.              $paged = get_query_var('page');
  639.         } else {
  640.              $paged = 1;
  641.         }
  642.  
  643.         $offset = $itemcount * ($paged - 1);
  644.  
  645.         if(!is_array($this->image_array['url'])) return;
  646.  
  647.         $this->image_array['url'] = array_slice($this->image_array['url'], $offset, $itemcount);
  648.         $this->image_array['link'] = array_slice($this->image_array['link'], $offset, $itemcount);
  649.         $this->image_array['id'] = array_slice($this->image_array['id'], $offset, $itemcount);
  650.         $this->slicecount = $itemcount;
  651.  
  652.         $output = "";
  653.  
  654.         foreach($this->image_array['url'] as $key => $attachment)
  655.         {
  656.  
  657.             $exif_data = avia_exif_data($this->image_array['id'][$key]);
  658.             $exif = $this->exif_container($this->image_array['id'][$key], true, $exif_data);
  659.             $title = $desc = "";
  660.             if(isset($exif_data['title'][1])) $title = strip_tags($exif_data['title'][1]);
  661.             if(isset($exif_data['description'][1])) $desc = strip_tags($exif_data['description'][1]);
  662.  
  663.             if($title == "-") $title = $desc = "";
  664.             $output .= "<div class='masonry-item'>";
  665.             $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>";
  666.             if($exif)
  667.             {
  668.                 $output .= "<div class='masonry-content'>";
  669.                 $output .=  $exif;
  670.                 $curpage = curPageURL();
  671.                 $imgurl = $this->image_array['url'][$key];
  672.                 $pinit = "<a href=\"http://pinterest.com/pin/create/button/?url=".$curpage."&media=".$imgurl."\" class=\"noLightbox pin-it-button \" count-layout=\"horizontal\">
  673.             <img  class=\"noLightbox\" border=\"0\" src=\"//assets.pinterest.com/images/PinExt.png\" title=\"Pin It\" /></a>";
  674.             $output .= $pinit;
  675.                 $output .= "</div>";
  676.             }
  677.             $output .= "</div>";
  678.  
  679.         }
  680.  
  681.         return $output;
  682.     }
  683.  
  684. }
  685.  
  686.  
  687.  
  688. /*helper function for exif data*/
  689.  
  690.  
  691. function avia_exif_data($attachment_id = "")
  692. {
  693.     $exif = array('title'=>'', 'description' => '', 'aperture'=>'', 'credit'=>'', 'camera'=>'', 'copyright'=>'', 'focal_length'=>'', 'iso'=>'','shutter_speed'=>'','created_timestamp'=>'' );
  694.     if(!$attachment_id) return $exif;
  695.  
  696.     $post = get_post($attachment_id);
  697.     $meta = wp_get_attachment_metadata($attachment_id, FALSE);
  698.     $meta = $meta['image_meta'];
  699.  
  700.  
  701.  
  702.     if(!empty($meta['aperture']))           {   $exif['aperture']    = array(__('Aperture','avia_framework'), $meta['aperture']);       }
  703.     if(!empty($meta['credit']))             {   $exif['credit']      = array(__('Credit','avia_framework'), str_replace('©','&copy;', $meta['credit']));     }
  704.     if(!empty($meta['camera']))             {   $exif['camera']      = array(__('Camera','avia_framework'), $meta['camera']);       }
  705.     if(!empty($meta['copyright']))          {   $exif['copyright']   = array(__('Copyright','avia_framework'), str_replace('©','&copy;', $meta['copyright']));       }
  706.     if(!empty($meta['focal_length']))       {   $exif['focal_length']= array(__('Focal Length','avia_framework'), $meta['focal_length']);       }
  707.     if(!empty($meta['iso']))                {   $exif['iso']         = array(__('ISO','avia_framework'), $meta['iso']);     }
  708.     if(!empty($meta['shutter_speed']))      {   $exif['shutter_speed']       = array(__('Shutter','avia_framework'), $meta['shutter_speed']);       }
  709.     if(!empty($meta['created_timestamp']))  {   $exif['created_timestamp']  = array(__('Created','avia_framework'), date( "F d, Y - H:i", $meta['created_timestamp']));     }
  710.     if(!empty($post->post_title))           {   $exif['title']       = array(__('Title','avia_framework'), $post->post_title);          }
  711.     if(!empty($post->post_content))         {   $exif['description'] = array(__('Description','avia_framework'), $post->post_content);  }
  712.     if(!empty($post->post_excerpt) &&
  713.         empty($post->post_content))         {   $exif['description'] = array(__('Description','avia_framework'), $post->post_content);  }
  714.  
  715.     return $exif;
  716. }