Example #1
0
function oxy_get_portfolio_item_data($item)
{
    // setup post data
    global $post;
    $post = $item;
    setup_postdata($post);
    global $more;
    // Declare global $more (before the loop).
    $more = 0;
    // grab the featured image
    $full_image_id = get_post_thumbnail_id($post->ID);
    $full_image_src = wp_get_attachment_image_src($full_image_id, 'full');
    // create info data structure
    $info = new stdClass();
    $info->title = get_the_title($post->ID);
    if (false !== $full_image_src) {
        $info->full_image_url = $full_image_src[0];
    } else {
        $info->full_image_url = '';
    }
    // set default popup link
    $info->popup_link = $info->full_image_url;
    $info->isGallery = false;
    // post format specific data
    $format = get_post_format($post->ID);
    if (false === $format) {
        $format = 'standard';
    }
    switch ($format) {
        case 'standard':
            $info->icon = 'fa fa-search-plus';
            $info->popup_class = 'magnific';
            break;
        case 'image':
            $info->icon = 'fa fa-picture-o';
            $info->popup_class = 'magnific';
            break;
        case 'video':
            $info->icon = 'fa fa-play';
            $info->popup_class = 'magnific-vimeo';
            $video_shortcode = oxy_get_content_shortcode($post, 'embed');
            if ($video_shortcode !== null) {
                if (isset($video_shortcode[5])) {
                    $video_shortcode = $video_shortcode[5];
                    if (isset($video_shortcode[0])) {
                        $info->popup_link = $video_shortcode[0];
                    }
                }
            }
            break;
        case 'audio':
            $info->icon = 'fa fa-play';
            $info->popup_class = 'magnific-audio';
            $audio_shortcode = oxy_get_content_shortcode($post, 'audio');
            if ($audio_shortcode !== null) {
                $audio_src = null;
                if (array_key_exists(3, $audio_shortcode)) {
                    if (array_key_exists(0, $audio_shortcode[3])) {
                        $audio_attrs = shortcode_parse_atts($audio_shortcode[3][0]);
                        if (array_key_exists('src', $audio_attrs)) {
                            $info->popup_link = $audio_attrs['src'];
                        }
                    }
                }
            }
            break;
        case 'gallery':
            $info->icon = 'fa fa-search-plus';
            $info->popup_class = 'magnific-gallery';
            $info->isGallery = true;
            $gallery_ids = oxy_get_content_gallery($post);
            if ($gallery_ids !== null) {
                if (count($gallery_ids) > 0) {
                    // ok lets create a gallery
                    $gallery_rel = 'rel="gallery' . $post->ID . '"';
                    $gallery_images = array();
                    foreach ($gallery_ids as $gallery_image_id) {
                        $gallery_image = wp_get_attachment_image_src($gallery_image_id, 'full');
                        $gallery_images[] = $gallery_image[0];
                    }
                    $info->gallery_links = implode(",", $gallery_images);
                }
            }
            break;
    }
    $info->item_link = get_permalink($post->ID);
    return $info;
}
Example #2
0
function oxy_shortcode_appland_gallery($atts, $content = '')
{
    // setup options
    extract(shortcode_atts(array('count' => 3, 'columns' => 3, 'rows' => 2, 'gallery' => ''), $atts));
    $query_options = array('post_type' => 'oxy_gallery_item', 'numberposts' => $count, 'orderby' => 'menu_order', 'order' => 'ASC');
    $filters = get_terms('oxy_gallery_categories', array('hide_empty' => 1));
    if (!empty($gallery)) {
        $galleries = explode(',', $gallery);
        $query_options['tax_query'][] = array('taxonomy' => 'oxy_gallery_categories', 'field' => 'slug', 'terms' => $galleries);
    }
    $span = $columns == 3 ? 'span4' : 'span3';
    // fetch posts
    $attachments = get_posts($query_options);
    $attachments_count = count($attachments);
    $output = '';
    //  ----------------------
    $span_width = $columns > 0 ? floor(12 / $columns) : 12;
    $gallery_id = 'gallery-' . rand(1, 100);
    $output = '<div class="carousel slide thumbs" id="' . $gallery_id . '">';
    $output .= '<div class="carousel-inner">';
    $output .= '<div class="active item">';
    $output .= '<ul class="thumbnails thumbnail-list">';
    $item = 1;
    foreach ($attachments as $attachment) {
        global $post;
        $post = $attachment;
        setup_postdata($post);
        $format = get_post_format($post->ID);
        if (false === $format) {
            $format = 'standard';
        }
        $use_magnific = get_post_meta($post->ID, THEME_SHORT . '_open_magnific', true);
        $link = get_post_meta($post->ID, THEME_SHORT . '_external_link', true);
        if ($link) {
            // overide magnific settings
            $use_magnific = false;
            $popup_class = '';
            $full = $link;
        }
        $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'large');
        $extra_gallery_images = array();
        $gallery_links = "";
        if ($use_magnific) {
            switch ($format) {
                case 'gallery':
                    $gallery_ids = oxy_get_content_gallery($post);
                    if ($gallery_ids !== null) {
                        if (count($gallery_ids) > 0) {
                            // use the first image as thumbnail for the gallery
                            // $gallery_thumb = wp_get_attachment_image_src( $gallery_ids[0], 'full');
                            // $thumbnail = $gallery_thumb;
                            // remove first gallery image from array
                            // array_shift( $gallery_ids );
                            foreach ($gallery_ids as $gallery_image_id) {
                                $gallery_image = wp_get_attachment_image_src($gallery_image_id, 'full');
                                $extra_gallery_images[] = $gallery_image[0];
                            }
                        }
                        $popup_class = 'popup-gallery';
                        $gallery_links = implode(",", $extra_gallery_images);
                    }
                    break;
                case 'video':
                    $video_shortcode = oxy_get_content_shortcode($post, 'embed');
                    if ($video_shortcode !== null) {
                        if (isset($video_shortcode[5])) {
                            $video_shortcode = $video_shortcode[5];
                            if (isset($video_shortcode[0])) {
                                $popup_class = 'popup-video';
                                $full = $video_shortcode[0];
                            }
                        }
                    }
                    break;
                default:
                case 'standard':
                    $full = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full');
                    $full = $full[0];
                    $popup_class = 'popup-image';
                    break;
            }
        }
        if ($item > $columns * $rows) {
            $output .= '</ul></div><div class="item"><ul class="thumbnails thumbnail-list">';
            $item = 1;
        }
        $output .= '<li class="span' . $span_width . '">';
        $output .= '<figure class="thumbnail-figure">';
        $output .= '<figcaption>';
        $output .= get_the_excerpt();
        $output .= '</figcaption>';
        if ($use_magnific || $link) {
            $output .= '<a class="popup-link ' . $popup_class . '" href="' . $full . '">';
        }
        $output .= '<img src="' . $thumbnail[0] . '"';
        if ($use_magnific || $link) {
            $output .= "" !== $gallery_links ? 'data-links="' . $gallery_links . '"' : "";
            $output .= '><i></i>';
            $output .= '</a>';
        }
        $output .= '</figure></li>';
        $item++;
    }
    $output .= '</ul>';
    $output .= '</div></div>';
    $output .= '<a class="carousel-control left" data-slide="prev" href="#' . $gallery_id . '"><i class="icon-chevron-left"></i></a>';
    $output .= '<a class="carousel-control right" data-slide="next" href="#' . $gallery_id . '"><i class="icon-chevron-right"></i></a>';
    $output .= '</div>';
    wp_reset_postdata();
    return $output;
}
Example #3
0
    }
    ?>
            <?php 
    $magnific_link = '';
    $magnific_type = 'image';
    $format = get_post_meta($post->ID, THEME_SHORT . '_post_type', true);
    switch ($format) {
        case 'video':
            $magnific_type = 'video';
            $video = get_post_meta($post->ID, THEME_SHORT . '_post_video_link', true);
            $magnific_link = $video;
            break;
        case 'gallery':
            $magnific_type = 'gallery';
            $gallery_content = get_post_meta($post->ID, THEME_SHORT . '_post_gallery', true);
            $magnific_link = oxy_get_content_gallery($gallery_content);
            break;
        default:
        case 'standard':
            // do nothing default is image with no link
            break;
    }
    ?>

            <div class="masonry-item portfolio-item <?php 
    echo implode(' ', $post->classes);
    ?>
" data-menu-order="<?php 
    echo $post->menu_order;
    ?>
" data-date="<?php