protected function content($atts, $content = null) { extract(shortcode_atts(array('images' => '', 'img_width' => '9999', 'img_height' => '9999', 'columns' => 4, 'grid_style' => '', 'thumbnail_link' => '', 'custom_links' => '', 'custom_links_target' => '_self', 'title' => false, 'black_white' => false, 'el_id' => '', 'el_class' => '', 'css_animation' => '', 'anim_type' => '', 'anim_delay' => '', 'css' => ''), $atts)); $sc_class = 'wt_gallery_grid_sc'; // Img Container Classes $sc_classes = array(); // Adding placeholder images if no image was set if ($images == '') { switch ($columns) { case 1: $images = '-1'; break; case 2: $images = '-1,-2'; break; case 3: $images = '-1,-2,-3'; break; case 4: $images = '-1,-2,-3,-4'; break; case 6: default: $images = '-1,-2,-3,-4,-5,-6'; break; } } // Get Attachments $images = explode(',', $images); $i = -1; $id = mt_rand(9999, 99999); if (trim($el_id) != false) { $el_id = esc_attr(trim($el_id)); } else { $el_id = $sc_class . '-' . $id; } // Custom Links if ($thumbnail_link == 'custom_link') { $custom_links = explode(',', $custom_links); } // Column Class if ($columns == '1') { $sc_classes[] = 'wt_gallery_1_col'; } else { $sc_classes[] = 'wt_gallery_' . $columns . '_cols'; } // Lightbox Class if ($thumbnail_link == 'lightbox') { $sc_classes[] = 'wt_gallery_lightbox'; } // No Margin Class if ($grid_style == 'no-margins') { $sc_classes[] = 'wt_gallery_no_margins clearfix'; } else { $sc_classes[] = 'row'; } $sc_classes = implode(' ', $sc_classes); if ($sc_classes != '') { $sc_classes = ' ' . $sc_classes; } $sc_class = $sc_class . $sc_classes; $el_class = esc_attr($this->getExtraClass($el_class)); $css_class = apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, $sc_class . $el_class . vc_shortcode_custom_css_class($css, ' '), $this->settings['base']); //$css_class .= $this->wt_sc->getWTCSSAnimationClass($css_animation,$anim_type); //$anim_data = $this->wt_sc->getWTCSSAnimationData($css_animation,$anim_delay); // Load prettyphoto scripts & styles if ($thumbnail_link == 'lightbox') { wp_enqueue_script('prettyphoto'); wp_enqueue_style('prettyphoto'); } // Output posts if ($images) { // Img Container Classes $classes = array(); switch ($columns) { case 1: $classes[] = 'col-xs-12 col-sm-12 col-lg-12 col-md-12'; break; case 2: $classes[] = 'col-xs-6 col-sm-6 col-md-6 col-lg-6'; break; case 3: $classes[] = 'col-xs-6 col-sm-6 col-md-4 col-lg-4'; break; case 4: $classes[] = 'col-xs-6 col-sm-6 col-md-3 col-lg-3'; break; case 6: default: $classes[] = 'col-xs-6 col-sm-6 col-md-2 col-lg-2'; break; } if ($black_white == 'yes') { $classes[] = 'wt_grayscale'; } $classes = implode(' ', $classes); wp_enqueue_script('waypoints'); // VC file $output = '<div id="' . $el_id . '" class="' . $css_class . '">'; $count = 0; foreach ($images as $attach_id) { $image_output = ''; $i++; $delay = $count * 150; $count++; // if image alt not set then take it's title $attachment_meta = WT_WpGetAttachment($attach_id); if (!empty($attachment_meta['alt'])) { $img_title = $attachment_meta['alt']; } else { $img_title = $attachment_meta['title']; } $img = $attachment_meta['src']; //$img = wp_get_attachment_url( $attach_id ); if ('9999' != $img_width && '9999' != $img_height) { $width_inline = $img_width; $height_inline = $img_height; } else { $image_meta = wp_get_attachment_image_src($attach_id, 'full', true); $width_inline = $image_meta[1]; // get original image width $height_inline = $image_meta[2]; // get original image height } if ($grid_style == 'no-margins') { $imgThumb = ''; } else { $imgThumb = ' class="img-thumbnail"'; } if ($attach_id > 0) { // Crop featured images if necessary if (function_exists('aq_resize')) { $thumb_hard_crop = '9999' == $img_height ? false : true; $cropped_img = aq_resize($img, $img_width, $img_height, $thumb_hard_crop); } $img_output = '<img' . $imgThumb . ' src="' . $cropped_img . '" width="' . $width_inline . '" height="' . $height_inline . '" alt="' . $img_title . '" />'; } else { // If no image was set then show placeholders $img_output = '<img' . $imgThumb . ' src="' . vc_asset_url('vc/no_image.png') . '" />'; } // Image output depending of image link if ($thumbnail_link == 'lightbox') { $image_output .= $img_output; $icon = '<i class="entypo-search"></i>'; $image_output .= '<div class="wt_gallery_overlay">'; $image_output .= '<a href="' . $img . '" title="' . $img_title . '" class="wt_image_zoom" data-rel="lightbox[gallery_' . $id . ']">' . $icon . '</a>'; if ($title == 'yes') { $image_output .= '<h3>' . $img_title . '</h3>'; } $image_output .= '</div>'; } elseif ($thumbnail_link == 'custom_link') { $custom_link = !empty($custom_links[$i]) ? $custom_links[$i] : '#'; if ($custom_link == '#') { $image_output .= $img_output; } else { $image_output .= '<a href="' . $custom_link . '" title="' . $img_title . '" target="' . $custom_links_target . '">'; $image_output .= $img_output; $image_output .= '</a>'; } } else { $image_output .= $img_output; } $output .= '<article class="wt_gallery_grid_item ' . $classes . ' wt_col_' . $count . ' wt_animate wt_animate_if_visible" data-animation="flipInX" data-animation-delay="' . $delay . '">'; $output .= "\n\t" . '<div class="wt_gallery_item_inner">'; $output .= "\n\t\t" . $image_output; $output .= "\n\t" . '</div>'; $output .= '</article>'; if ($count == $columns) { $count = 0; } // reset column number } $output .= '</div>'; } // End has posts check // Reset query wp_reset_postdata(); return $output; }
protected function content($atts, $content = null) { extract(shortcode_atts(array('images' => '', 'img_size' => 'thumbnail', 'type' => 'simple', 'columns' => 6, 'hover_border' => false, 'black_white' => false, 'tooltip' => false, 'tooltip_placement' => 'top', 'custom_links' => false, 'custom_links_textarea' => '', 'custom_links_target' => '_self', 'owl_speed' => 600, 'owl_pagspeed' => 1000, 'owl_autoplay' => 'false', 'owl_stoponhover' => 'false', 'owl_navigation' => 'false', 'owl_pagination' => 'false', 'owl_items' => 6, 'owl_itemsdesktop' => 4, 'owl_itemssmalldesktop' => 4, 'owl_itemstablet' => 3, 'owl_itemsmobile' => 2, 'owl_itemsmobilesmall' => 1, 'el_id' => '', 'el_class' => '', 'css_animation' => '', 'anim_type' => '', 'anim_delay' => '', 'css' => ''), $atts)); $gal_images = ''; $link_start = ''; $link_end = ''; $owl_speed = (int) $owl_speed; $owl_pagspeed = (int) $owl_pagspeed; $owl_autoplay = esc_attr($owl_autoplay); $owl_stoponhover = esc_attr($owl_stoponhover); $owl_navigation = esc_attr($owl_navigation); $owl_pagination = esc_attr($owl_pagination); $owl_items = (int) $owl_items; $owl_itemsdesktop = (int) $owl_itemsdesktop; $owl_itemssmalldesktop = (int) $owl_itemssmalldesktop; $owl_itemstablet = (int) $owl_itemstablet; $owl_itemsmobile = (int) $owl_itemsmobile; $owl_itemsmobilesmall = (int) $owl_itemsmobilesmall; if ($images == '') { $images = '-1,-2,-3'; } // adding placeholder images if no image was set if ($custom_links == true) { $custom_links_textarea = explode(',', $custom_links_textarea); } $images = explode(',', $images); $i = -1; $count = 0; $sc_class = 'wt_clients_sc'; $id = mt_rand(9999, 99999); if (trim($el_id) != false) { $el_id = esc_attr(trim($el_id)); } else { $el_id = $sc_class . '-' . $id; } $img_size = esc_html($img_size); if ($type == 'simple') { $carousel = ''; } else { wp_print_scripts('owlCarousel'); $carousel = ' wt_owl_carousel '; } $sc_class .= ' wt_align_center' . $carousel; $el_class = esc_attr($this->getExtraClass($el_class)); $css_class = apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, $sc_class . $el_class . vc_shortcode_custom_css_class($css, ' '), $this->settings['base']); $css_class .= $this->wt_sc->getWTCSSAnimationClass($css_animation, $anim_type); $anim_data = $this->wt_sc->getWTCSSAnimationData($css_animation, $anim_delay); switch ($columns) { case 3: $col_out = ' col-xs-4 col-sm-4 col-md-4 col-lg-4'; break; case 4: $col_out = ' col-xs-4 col-sm-4 col-md-3 col-lg-3'; break; case 6: default: $col_out = ' col-xs-4 col-sm-4 col-md-2 col-lg-2'; break; } if ($hover_border == true) { $hover_border = ' wt_client_border'; } else { $hover_border = ''; } if ($black_white == true) { $black_white = ' wt_grayscale'; } else { $black_white = ''; } if ($tooltip == true) { $tooltip_out = ' data-toggle="tooltip" data-placement="' . $tooltip_placement . '"'; } else { $tooltip_out = ''; } if ($type == 'simple') { wp_enqueue_script('waypoints'); // VC file $carousel_data = ''; } else { $carousel_data = ' data-owl-speed="' . $owl_speed . '" data-owl-pagSpeed="' . $owl_pagspeed . '" data-owl-autoPlay="' . $owl_autoplay . '" data-owl-stopOnHover="' . $owl_stoponhover . '" data-owl-navigation="' . $owl_navigation . '" data-owl-pagination="' . $owl_pagination . '" data-owl-items="' . $owl_items . '" data-owl-itemsDesktop="' . $owl_itemsdesktop . '" data-owl-itemsSmallDesktop="' . $owl_itemssmalldesktop . '" data-owl-itemsTablet="' . $owl_itemstablet . '" data-owl-itemsMobile="' . $owl_itemsmobile . '" data-owl-itemsMobileSmall="' . $owl_itemsmobilesmall . '"'; } $output = '<div id="' . $el_id . '" class="' . $css_class . '"' . $anim_data . $carousel_data . '>'; foreach ($images as $attach_id) { $i++; $count++; $delay = $count * 100; if ($attach_id > 0) { $img = wpb_getImageBySize(array('attach_id' => $attach_id, 'thumb_size' => $img_size)); } else { $img = array(); $img['thumbnail'] = '<img src="' . vc_asset_url('vc/no_image.png') . '" />'; } $img_output = $img['thumbnail']; // if image caption not set then take it's title $attachment_meta = WT_WpGetAttachment($attach_id); if (!empty($attachment_meta['caption'])) { $img_title = $attachment_meta['caption']; } else { $img_title = $attachment_meta['title']; } // output for client image if ($custom_links == true && isset($custom_links_textarea[$i]) && $custom_links_textarea[$i] != '') { $output_image = '<a href="' . $custom_links_textarea[$i] . '"' . ' title="' . $img_title . '"' . ' target="' . $custom_links_target . '"' . $tooltip_out . '>' . $img_output . '</a>'; } elseif ($tooltip == true) { $output_image = '<a href="#"' . $tooltip_out . ' title="' . $img_title . '">' . $img_output . '</a>'; } else { $output_image = $img_output; } // display simple images or with custom links if ($type == 'simple') { $output .= '<div class="wt_client' . $hover_border . $black_white . $col_out . ' wt_animate wt_animate_if_visible" data-animation="fadeInUp" data-animation-delay="' . $delay . '">'; $output .= "\n\t" . $output_image; $output .= '</div>'; } else { $output .= "\n\t" . '<div class="wt_client item' . $hover_border . $black_white . '">'; $output .= "\n\t\t" . $output_image; $output .= "\n\t" . '</div>'; } if ($count == $columns) { $count = 0; } // reset column number } $output .= '</div>'; return $output; }