Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SEARCH FOR THIS FUNCTION:
- static function get_post_img_mosaic($post_id){
- EDIT THE FUNCTION (hole function):
- /*generates content for gallery slider when 'mosaic' mode is set*/
- static function get_post_img_mosaic($post_id){
- /*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 the 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
- $attachments = get_children(array('post_parent' => $post_id,
- 'post_status' => 'inherit',
- 'post_type' => 'attachment',
- 'post_mime_type' => 'image',
- 'order' => 'ASC',
- 'orderby' => 'menu_order ID'));
- }
- if( isset($attachments) && count($attachments) > 0){
- ?>
- <div class=" row mosaic-view thumb-view gallery-mosaic-view">
- <div class="twelve columns">
- <div class="row masonry for-mosaic" >
- <?php
- $counter = 0;
- $pretty_colection_id = mt_rand(0,99999);
- foreach($attachments as $att_id => $attachment) {
- $options = array('post_number' => $counter);
- $attachment_info = get_post($att_id); //deb::e($attachment_info );
- if( is_object($attachment_info) && isset($attachment_info->post_excerpt)){
- $caption = $attachment_info->post_content;
- }else{
- $caption = '';
- }
- $img_title = $attachment_info -> post_title;
- //------------------------------------
- $default_options = array('post_number' => 0); /*default options*/
- extract( $options ); /*extract the passed options*/
- extract( $default_options, EXTR_PREFIX_SAME, "default"); /* eXtract default options with 'default' prefix in case the option with the same name was already passed */
- $position_info = post::get_mosaicinfo_by_order($post_number % 12);
- $container_width = $position_info['width'];
- $thumb_size = $position_info['thumb_size'];
- $container_class = $position_info['container_class'];
- if( trim($container_class) == 'large-mosaic-elem'){
- $thumb_width = 720;
- $thumb_height = 720;
- $thumb_no_img = 'thumb-transparent-img.png';
- }elseif(trim($container_class) == 'long-mosaic-elem'){
- $thumb_width = 340;
- $thumb_height = 720;
- $thumb_no_img = 'no-img-long.png';
- }else{
- $thumb_width = 340;
- $thumb_height = 340;
- $thumb_no_img = 'thumb-transparent-img.png';
- }
- $no_img_class = '';
- if(options::logic( 'blog_post' , 'disable_hover_effect' )){
- $disable_hover_effect = '';
- } else { $disable_hover_effect = 'hovermove'; }
- $custom_fields = get_post_custom($att_id);
- //deb::e($custom_fields);
- $custom_link_db = '';
- $custom_link_tab = '';
- $tab = '';
- if (isset($custom_fields['custom_link'])) {
- $custom_link_db = $custom_fields['custom_link'][0];
- $custom_link_tab = $custom_fields['custom_link_tab'][0];
- $tab = $custom_link_tab == 'yes' ? 'target="_blank"' : '';
- }
- ?>
- <div class="masonry_elem <?php echo $container_width; ?> columns">
- <div class="thumb-elem <?php echo $disable_hover_effect?> <?php echo $container_class; ?> large-mosaic-elem">
- <header class="thumb-elem-header">
- <div class="featimg ">
- <?php
- $size = 'grid_small';
- $img_url = wp_get_attachment_url( $att_id ,'full'); //get img URL
- $img_src = aq_resize( $img_url, get_aqua_size($thumb_size), get_aqua_size($thumb_size, 'height'), true, false); //crop img
- //====================
- //$img_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ) , $thumb_size );
- $img_width = $img_src[1];
- $img_height = $img_src[2];
- if($img_width != $thumb_width || $img_height != $thumb_height){
- /*if the image doesn't have the requested size then we will add a transparent square image and will give position absolute to the original image*/
- $original_img_style = 'style="position:absolute"';
- }else{
- $original_img_style = '';
- }
- ?>
- <img class="the-thumb" src="<?php echo $img_src[0]; ?>" alt="" style="position:absolute" />
- <img src="<?php echo get_template_directory_uri() ?>/images/<?php echo $thumb_no_img; ?>" alt="<?php echo $caption; ?>" />
- <div class="image-title"><?php echo $img_title; ?></div>
- <div class="image-description"><?php echo $caption; ?></div>
- <?php if( options::logic( 'blog_post' , 'enb_lightbox' ) && $custom_link_db == ''){ ?>
- <div class="zoom-image">
- <a href="<?php echo $img_url; ?>" data-rel="prettyPhoto[<?php echo $pretty_colection_id; ?>]" title="<?php echo $img_title.' - '.$caption; ?>"> </a>
- </div>
- <?php } else if ($custom_link_db != '') { ?>
- <div class="custom-link">
- <div class="icon-link"></div>
- <a href="<?php echo $custom_link_db;?>" <?php echo $tab; ?> > </a>
- </div>
- <?php } ?>
- </div>
- </header>
- </div>
- </div>
- <?php
- $counter ++;
- }
- ?>
- </div>
- </div>
- </div>
- <?php
- }else{
- _e('This gallery has no images attached', 'cosmotheme');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement