Exemplo n.º 1
0
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;
}