function wpv_get_portfolio_options($group, $rel_group) { global $post; $res = array(); $res['image'] = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_id()), 'full', true); $res['type'] = wpv_default(get_post_meta(get_the_id(), 'portfolio_type', true), 'image'); $res['width'] = ''; $res['height'] = ''; $res['iframe'] = ''; $res['link_target'] = '_self'; $res['rel'] = $group == 'true' ? ' rel="' . $rel_group . '"' : ''; // calculate some options depending on the portfolio item's type if ($res['type'] == 'image' || $res['type'] == 'html') { $res['href'] = $res['image'][0]; $res['lightbox'] = ' vamtam-lightbox'; } elseif ($res['type'] == 'video') { $res['href'] = get_post_meta(get_the_id(), 'wpv-portfolio-format-video', true); if (empty($res['href'])) { $res['href'] = $res['image'][0]; } } elseif ($res['type'] == 'link') { $res['href'] = get_post_meta(get_the_ID(), 'wpv-portfolio-format-link', true); $res['link_target'] = get_post_meta(get_the_ID(), '_link_target', true); $res['link_target'] = $res['link_target'] ? $res['link_target'] : '_self'; $res['lightbox'] = ' no-lightbox'; $res['rel'] = ''; } elseif ($res['type'] == 'gallery') { list($res['gallery'], ) = WpvPostFormats::get_first_gallery(get_the_content(), null, WpvPostFormats::get_thumb_name(array('p' => $post))); } elseif ($res['type'] == 'document') { if (is_single()) { $res['href'] = $res['image'][0]; $res['lightbox'] = ' vamtam-lightbox'; } else { $res['href'] = get_permalink(); $res['lightbox'] = ' no-lightbox'; } $res['rel'] = ''; } return $res; }
<?php /** * Single portfolio content template * @package wpv */ $is_ajax = isset($_SERVER['HTTP_X_VAMTAM']) && $_SERVER['HTTP_X_VAMTAM'] == 'ajax-portfolio'; $client = get_post_meta(get_the_id(), 'portfolio-client', true); $logo = get_post_meta(get_the_id(), 'portfolio-logo', true); $client = preg_replace('@</\\s*([^>]+)\\s*>@', '</$1>', $client); $content = get_the_content(); $portfolio_options = wpv_get_portfolio_options('true', ''); if ($portfolio_options['type'] == 'gallery') { list(, $content) = WpvPostFormats::get_first_gallery($content); } $content = apply_filters('the_content', $content); $has_right_column = !empty($logo) || !empty($client); $left_column_width = $has_right_column ? 'grid-4-5' : 'grid-1-1 last'; ?> <div class="row portfolio-content"> <div class="<?php echo $left_column_width; ?> "> <?php if ($is_ajax) { ?> <?php WpvTemplates::breadcrumbs(); WpvTemplates::page_header(false, get_the_title());
global $wpv_has_header_sidebars; if ($wpv_has_header_sidebars) { WpvTemplates::header_sidebars(); } $column_width = wpv_get_central_column_width(); $size = $column_width; ?> <div class="clearfix"> <?php if ($type != 'document') { ?> <div class="portfolio_image_wrapper fullwidth-folio"> <?php if ($type == 'gallery') { list($gallery, ) = WpvPostFormats::get_first_gallery(get_the_content(), null, 'single-portfolio'); echo do_shortcode($gallery); } elseif ($type == 'video') { global $wp_embed; echo do_shortcode($wp_embed->run_shortcode('[embed width="' . $size . '"]' . $href . '[/embed]')); } elseif ($type == 'html') { echo do_shortcode(get_post_meta(get_the_ID(), 'portfolio-top-html', true)); } else { the_post_thumbnail('single-portfolio'); } ?> </div> <?php } ?> </div>
/** * returns a list of gallery ids * * @param $post WP_Post regular WP post object * @return array */ private static function get_gallery_images($post) { list($gallery, ) = WpvPostFormats::get_first_gallery($post->post_content, null, 'full'); $pattern = get_shortcode_regex(); preg_match("/{$pattern}/s", $gallery, $matches); $attr = shortcode_atts(array('ids' => ''), shortcode_parse_atts($matches[3])); return empty($attr['ids']) ? array() : explode(',', $attr['ids']); }