$img['thumbnail'] = str_replace('<img ', '<img data-vc-zoom="' . $large_img_src . '" ', $img['thumbnail']); break; } // backward compatibility if (vc_has_class('prettyphoto', $el_class)) { $el_class = vc_remove_class('prettyphoto', $el_class); } $wrapperClass = 'vc_single_image-wrapper ' . $style . ' ' . $border_color; if ($link) { $a_attrs['href'] = $link; $a_attrs['target'] = $img_link_target; if (!empty($a_attrs['class'])) { $wrapperClass .= ' ' . $a_attrs['class']; unset($a_attrs['class']); } $html = '<a ' . vc_stringify_attributes($a_attrs) . ' class="' . $wrapperClass . '">' . $img['thumbnail'] . '</a>'; } else { $html = '<div class="' . $wrapperClass . '">' . $img['thumbnail'] . '</div>'; } $class_to_filter = 'wpb_single_image wpb_content_element vc_align_' . $alignment . ' ' . $this->getCSSAnimation($css_animation); $class_to_filter .= vc_shortcode_custom_css_class($css, ' ') . $this->getExtraClass($el_class); $css_class = apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, $class_to_filter, $this->settings['base'], $atts); if (in_array($source, array('media_library', 'featured_image')) && 'yes' === $add_caption) { $post = get_post($img_id); $caption = $post->post_excerpt; } else { if ('external_link' === $source) { $add_caption = 'yes'; } } if ('yes' === $add_caption && '' !== $caption) {
/** * @param array $params * * @since 4.2 * vc_filter: vc_wpb_getimagesize - to override output of this function * @return array|bool */ function wpb_getImageBySize($params = array()) { $params = array_merge(array('post_id' => null, 'attach_id' => null, 'thumb_size' => 'thumbnail', 'class' => ''), $params); if (!$params['thumb_size']) { $params['thumb_size'] = 'thumbnail'; } if (!$params['attach_id'] && !$params['post_id']) { return false; } $post_id = $params['post_id']; $attach_id = $post_id ? get_post_thumbnail_id($post_id) : $params['attach_id']; $attach_id = apply_filters('vc_object_id', $attach_id); $thumb_size = $params['thumb_size']; $thumb_class = isset($params['class']) && '' !== $params['class'] ? $params['class'] . ' ' : ''; global $_wp_additional_image_sizes; $thumbnail = ''; if (is_string($thumb_size) && (!empty($_wp_additional_image_sizes[$thumb_size]) && is_array($_wp_additional_image_sizes[$thumb_size]) || in_array($thumb_size, array('thumbnail', 'thumb', 'medium', 'large', 'full')))) { $attributes = array('class' => $thumb_class . 'attachment-' . $thumb_size); $thumbnail = wp_get_attachment_image($attach_id, $thumb_size, false, $attributes); } elseif ($attach_id) { if (is_string($thumb_size)) { preg_match_all('/\\d+/', $thumb_size, $thumb_matches); if (isset($thumb_matches[0])) { $thumb_size = array(); if (count($thumb_matches[0]) > 1) { $thumb_size[] = $thumb_matches[0][0]; // width $thumb_size[] = $thumb_matches[0][1]; // height } elseif (count($thumb_matches[0]) > 0 && count($thumb_matches[0]) < 2) { $thumb_size[] = $thumb_matches[0][0]; // width $thumb_size[] = $thumb_matches[0][0]; // height } else { $thumb_size = false; } } } if (is_array($thumb_size)) { // Resize image to custom size $p_img = wpb_resize($attach_id, null, $thumb_size[0], $thumb_size[1], true); $alt = trim(strip_tags(get_post_meta($attach_id, '_wp_attachment_image_alt', true))); $attachment = get_post($attach_id); if (!empty($attachment)) { $title = trim(strip_tags($attachment->post_title)); if (empty($alt)) { $alt = trim(strip_tags($attachment->post_excerpt)); // If not, Use the Caption } if (empty($alt)) { $alt = $title; } // Finally, use the title if ($p_img) { $attributes = vc_stringify_attributes(array('class' => $thumb_class, 'src' => $p_img['url'], 'width' => $p_img['width'], 'height' => $p_img['height'], 'alt' => $alt, 'title' => $title)); $thumbnail = '<img ' . $attributes . ' />'; } } } } $p_img_large = wp_get_attachment_image_src($attach_id, 'large'); return apply_filters('vc_wpb_getimagesize', array('thumbnail' => $thumbnail, 'p_img_large' => $p_img_large), $attach_id, $params); }
$large_img_src = $large_img_src[0]; } } $img['thumbnail'] = str_replace('<img ', '<img data-vc-zoom="' . $large_img_src . '" ', $img['thumbnail']); break; } // backward compatibility if (vc_has_class('prettyphoto', $el_class)) { $el_class = vc_remove_class('prettyphoto', $el_class); } $html = 'vc_box_shadow_3d' === $style ? '<span class="vc_box_shadow_3d_wrap">' . $img['thumbnail'] . '</span>' : $img['thumbnail']; $html = '<div class="vc_single_image-wrapper ' . $style . ' ' . $border_color . '">' . $html . '</div>'; if ($link) { $a_attrs['href'] = $link; $a_attrs['target'] = $img_link_target; $html = '<a ' . vc_stringify_attributes($a_attrs) . '>' . $html . '</a>'; } $class_to_filter = 'wpb_single_image wpb_content_element vc_align_' . $alignment . ' ' . $this->getCSSAnimation($css_animation); $class_to_filter .= vc_shortcode_custom_css_class($css, ' ') . $this->getExtraClass($el_class); $css_class = apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, $class_to_filter, $this->settings['base'], $atts); if (in_array($source, array('media_library', 'featured_image')) && 'yes' === $add_caption) { $post = get_post($img_id); $caption = $post->post_excerpt; } else { if ('external_link' === $source) { $add_caption = 'yes'; } } if ('yes' === $add_caption && '' !== $caption) { $html = ' <figure class="vc_figure">