Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*generates content for gallery slider when 'sly' mode is set*/
- static function get_post_img_slideshow($post_id, $size="gallery_format_slider"){
- /*check the meta data where the attached image ids are stored*/
- $post_image_gallery_meta = get_post_meta( $post_id, '_post_image_gallery', true );
- if(strlen($post_image_gallery_meta) && 'Array' != $post_image_gallery_meta){
- $product_image_gallery = $post_image_gallery_meta;
- $img_id_array = array_filter( explode( ',', $product_image_gallery ) );
- }else{
- //backward compatibility with version prev to 1.1
- $attachet_gallery_ids = meta::get_meta( $post_id, 'imagesattached' );
- if(isset($attachet_gallery_ids['img_ids']) && strlen($attachet_gallery_ids['img_ids'])){
- /*mata is stored as a string of numbers separated by comma (ex: 909,914,913,912,911,910,908)*/
- $img_id_array = explode(',', $attachet_gallery_ids['img_ids']); //create an array from the string
- }
- }
- if(isset($img_id_array) && is_array($img_id_array)){
- foreach ($img_id_array as $value) {
- $attachments[$value] = $value; // create attachments array in hte format that will work for us
- }
- }
- if(!isset($attachments)){ // if no meta is attached to the post then the gallery wil be created from attached images
- $thumb_ID = get_post_thumbnail_id($post_id);
- $attachments = get_children(array('post_parent' => $post_id,
- 'post_status' => 'inherit',
- 'post_type' => 'attachment',
- 'post_mime_type' => 'image',
- 'order' => 'ASC',
- 'exclude' => $thumb_ID,
- 'orderby' => 'menu_order ID'));
- }
- if(count($attachments) > 0){
- ?>
- <div class="entry-header" >
- <div class="frame" id="centered">
- <ul class="clearfix">
- <?php
- $pretty_colection_id = mt_rand(0,9999);
- if($size== "gallery_format_slider"){
- $images_to_show_first = 9;
- }else{
- $images_to_show_first = 5;
- }
- $additional_items = ''; /*in this string we will store the images that are left after loading the number of images defined in $images_to_show_first var*/
- $counter = 0;
- foreach($attachments as $att_id => $attachment) {
- $full_img_url = wp_get_attachment_url($att_id);
- $thumbnail_url = aq_resize( $full_img_url, get_aqua_size($size), get_aqua_size($size, 'height'), false, false ); //resize img, Return an array containing url, width, and height.
- //$thumbnail_url= wp_get_attachment_image_src( $att_id, $size);
- $alt = get_post_meta($att_id, '_wp_attachment_image_alt', true);
- if($counter < $images_to_show_first){
- $src = $thumbnail_url[0]; // for the first X images we will give original img src
- }else{
- $src = get_template_directory_uri().'/images/grey.gif'; // for the rest of the images we will load a 1px image to not load the page
- }
- //$caption = image::caption( $att_id );
- $attachment_info = get_post($att_id); //deb::e($attachment_info );
- $caption = $alt;
- global $wp_query;
- $post_now = $wp_query -> queried_object;
- ob_start();
- ob_clean();
- ?>
- <li class="relative">
- <?php if (options::logic('blog_post', 'show_sly_caption') && meta::logic( $post_now , 'gallerytype' , 'show_sly_caption' )) { ?>
- <div class="sly-caption"><?php echo $caption; ?></div>
- <?php }?>
- <img class="lazy" src="<?php echo $src; ?>" data-original="<?php echo $thumbnail_url[0]; ?>" alt="<?php echo $caption; ?>" width="<?php echo $thumbnail_url[1]; ?>" height="<?php echo $thumbnail_url[2]; ?>" data-width="<?php echo $thumbnail_url[1]; ?>" data-height="<?php echo $thumbnail_url[2]; ?>" alt="" />
- <?php if( options::logic( 'blog_post' , 'enb_lightbox' )){ ?>
- <div class="zoom-image">
- <a href="<?php echo $full_img_url; ?>" data-rel="prettyPhoto[<?php echo $pretty_colection_id; ?>]" title="<?php echo $caption; ?>"> </a>
- </div>
- <?php } if (options::logic('styling', 'stripes')) { ?>
- <div class="stripes" > </div>
- <?php }?>
- </li>
- <?php
- $li_item = ob_get_clean();
- if($counter < $images_to_show_first){
- // we output the first X images
- $src = $thumbnail_url[0];
- echo $li_item;
- }else{
- // the other images are stored into a string
- $additional_items .= $li_item;
- }
- $counter++;
- }
- ?>
- </ul>
- <?php
- if( strlen( $additional_items) ){
- //if there are any images in the additional items, then we will create a hidded DIV with this images
- echo '<div class="additional_items" style="display:none">'.$additional_items.'</div>';
- }
- ?>
- </div>
- <div class="scrollbar">
- <div class="handle">
- <div class="mousearea"></div>
- </div>
- </div>
- <div class="controls center">
- <button class="btn prev"><i class="icon-prev"></i></button>
- <button class="btn next"><i class="icon-next"></i></button>
- </div>
- </div>
- <?php
- }else{
- ?>
- <div class="entry-header noimages" >
- <div class="frame" id="centered">
- <h3><?php _e('There are no images attached to this gallery','cosmotheme'); ?></h3>
- </div>
- </div>
- <?php
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement