} // if we have post thumbnail and it's not hidden if (has_post_thumbnail() && $config->get('post.media.featured_image.enabled')) { array_unshift($media_items, absint(get_post_thumbnail_id())); } // open in lightbox $open_thumbnail_in_lightbox = $config->get('post.media.lightbox.enabled'); $media_type = $config->get('post.media.type'); $attachments_data = presscore_get_attachment_post_data($media_items); if (count($attachments_data) > 1) { // media html switch ($media_type) { case 'gallery': $gallery_columns = absint($config->get('post.media.gallery.columns')); $gallery_columns = $gallery_columns ? $gallery_columns : 4; $media_html = presscore_get_images_gallery_1($attachments_data, array('columns' => $gallery_columns, 'first_big' => $config->get('post.media.gallery.first_iamge_is_large'))); break; case 'list': $media_html = presscore_get_images_list($attachments_data, array('open_in_lightbox' => $open_thumbnail_in_lightbox)); break; default: // slideshow dimensions $slider_proportions = $config->get('post.media.slider.proportion'); if (!is_array($slider_proportions)) { $slider_proportions = array('width' => '', 'height' => ''); } $slider_proportions = wp_parse_args($slider_proportions, array('width' => '', 'height' => '')); $media_html = presscore_get_royal_slider($attachments_data, array('class' => array('slider-post'), 'width' => absint($slider_proportions['width']), 'height' => absint($slider_proportions['height']), 'style' => ' style="width: 100%;"')); } if ($media_html && in_array($media_type, array('list', 'gallery'))) { $media_html = sprintf('<div class="images-container">%s</div>', $media_html);
if ('list' != $layout) { if ('wide' == $preview_mode && !$config->get('all_the_same_width')) { $target_image_width = $config->get('target_width') * 3; $gallery_args['title_img_options'] = array('w' => round($target_image_width), 'z' => 0, 'hd_convert' => false); } else { $target_image_width = $config->get('target_width') * 1.5; $gallery_args['title_img_options'] = array('w' => round($target_image_width), 'z' => 0); } } echo presscore_get_images_gallery_hoovered($attachments_data, $gallery_args); break; default: if ('normal' == $preview_mode) { $class[] = 'format-gallery-normal'; } echo presscore_get_images_gallery_1($attachments_data, array('class' => $class, 'style' => $style)); } } ?> </div> <div class="blog-content wf-td"> <h2 class="entry-title"> <a href="<?php the_permalink(); ?> " title="<?php echo the_title_attribute('echo=0'); ?> " rel="bookmark"><?php the_title(); ?>
} // if we have post thumbnail and it's not hidden if (has_post_thumbnail() && $config->get('post.media.featured_image.enabled')) { array_unshift($media_items, absint(get_post_thumbnail_id())); } // open in lightbox $open_thumbnail_in_lightbox = $config->get('post.media.lightbox.enabled'); $media_type = $config->get('post.media.type'); $attachments_data = presscore_get_attachment_post_data($media_items); if (count($attachments_data) > 1) { // media html switch ($media_type) { case 'gallery': $gallery_columns = absint($config->get('post.media.gallery.columns')); $gallery_columns = $gallery_columns ? $gallery_columns : 4; $media_html = presscore_get_images_gallery_1($attachments_data, array('columns' => $gallery_columns, 'first_big' => $config->get('post.media.gallery.first_iamge_is_large'), 'style' => presscore_get_share_buttons_for_prettyphoto('photo'))); break; case 'list': $media_html = presscore_get_images_list($attachments_data, array('open_in_lightbox' => $open_thumbnail_in_lightbox, 'show_share_buttons' => true)); break; default: // slideshow dimensions $slider_proportions = $config->get('post.media.slider.proportion'); if (!is_array($slider_proportions)) { $slider_proportions = array('width' => '', 'height' => ''); } $slider_proportions = wp_parse_args($slider_proportions, array('width' => '', 'height' => '')); $media_html = presscore_get_royal_slider($attachments_data, array('class' => array('slider-post'), 'width' => absint($slider_proportions['width']), 'height' => absint($slider_proportions['height']), 'style' => ' style="width: 100%;"', 'show_info' => array('title', 'link', 'description', 'share_buttons'))); } if ($media_html && in_array($media_type, array('list', 'gallery'))) { $media_html = sprintf('<div class="images-container">%s</div>', $media_html);
public function shortcode($content = '', $attr = array()) { static $shortcode_instance = 0; // return if this is standard mode or gallery alredy modified if (!empty($content)) { return $content; } if (class_exists('Jetpack', false)) { $jetpack_active_modules = get_option('jetpack_active_modules'); if ($jetpack_active_modules && (in_array('carousel', $jetpack_active_modules) || in_array('tiled-gallery', $jetpack_active_modules))) { return $content; } } $shortcode_instance++; if (empty($attr['mode']) || 'standard' == $attr['mode']) { // retrun slightly modified gallery with preatty photo return $this->wp_gallery_with_lightbox($attr, $shortcode_instance); } $post = get_post(); if (isset($attr['orderby'])) { $attr['orderby'] = sanitize_sql_orderby($attr['orderby']); if (!$attr['orderby']) { unset($attr['orderby']); } } extract(shortcode_atts(array('mode' => 'metro', 'width' => 1200, 'height' => 500, 'order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post ? $post->ID : 0, 'size' => 'thumbnail', 'include' => '', 'exclude' => '', 'columns' => 3, 'first_big' => true), $attr, 'gallery')); $id = intval($id); if ('RAND' == $order) { $orderby = 'none'; } if (!empty($include)) { $_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby)); $attachments = array(); foreach ($_attachments as $key => $val) { $attachments[$val->ID] = $_attachments[$key]; } } elseif (!empty($exclude)) { $attachments = get_children(array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby)); } else { $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby)); } if (empty($attachments)) { return ''; } if (is_feed()) { $output = "\n"; foreach ($attachments as $att_id => $attachment) { $output .= wp_get_attachment_link($att_id, $size, true) . "\n"; } return $output; } $mode = in_array($mode, array('slideshow', 'metro')) ? $mode : 'metro'; $width = absint($width); $height = absint($height); $attachments_data = array(); foreach ($attachments as $id => $attachment) { $data = array(); // attachment meta $data['full'] = $data['width'] = $data['height'] = ''; $meta = wp_get_attachment_image_src($id, 'full'); if (!empty($meta)) { $data['full'] = esc_url($meta[0]); $data['width'] = absint($meta[1]); $data['height'] = absint($meta[2]); } $data['thumbnail'] = wp_get_attachment_image_src($id, 'thumbnail'); $data['alt'] = esc_attr(get_post_meta($id, '_wp_attachment_image_alt', true)); $data['caption'] = $attachment->post_excerpt; $data['description'] = $attachment->post_content; $data['title'] = get_the_title($id); $data['video_url'] = esc_url(get_post_meta($id, 'dt-video-url', true)); $data['link'] = esc_url(get_post_meta($id, 'dt-img-link', true)); $data['mime_type_full'] = get_post_mime_type($id); $data['mime_type'] = dt_get_short_post_myme_type($id); $data['ID'] = $id; if (!empty($attr['link']) && 'file' === $attr['link']) { $data['permalink'] = $data['full']; } elseif (!empty($attr['link']) && 'none' === $attr['link']) { $data['permalink'] = ''; } else { $data['permalink'] = get_permalink($id); } $attachments_data[] = apply_filters('presscore_get_attachment_post_data-attachment_data', $data, array_keys($attachments)); } $style = ' style="width: 100%;"'; if ('slideshow' == $mode) { $output = presscore_get_royal_slider($attachments_data, array('width' => $width, 'height' => $height, 'class' => array('slider-simple'), 'style' => $style)); } elseif ('metro' == $mode) { $metro_classes = array('shortcode-gallery'); if (!$first_big) { $metro_classes[] = 'shortcode-gallery-standard'; } $output = presscore_get_images_gallery_1($attachments_data, array('class' => $metro_classes, 'style' => $style, 'columns' => $columns, 'first_big' => apply_filters('dt_sanitize_flag', $first_big))); } return $output; }
// open in lightbox $open_thumbnail_in_lightbox = get_post_meta($post->ID, '_dt_project_options_open_thumbnail_in_lightbox', true); $attachments_data = presscore_get_attachment_post_data($media_items); if (count($attachments_data) > 1) { // media html switch ($media_type) { case 'gallery': $gallery_columns = get_post_meta($post->ID, '_dt_project_media_options_gallery_columns', true); $gallery_columns = $gallery_columns ? absint($gallery_columns) : 4; $gallery_make_first_big = get_post_meta($post->ID, '_dt_project_media_options_gallery_make_first_big', true); if (false === $gallery_make_first_big) { $gallery_make_first_big = 1; } else { $gallery_make_first_big = absint($gallery_make_first_big); } $media_html = presscore_get_images_gallery_1($attachments_data, array('columns' => $gallery_columns, 'first_big' => $gallery_make_first_big)); break; case 'list': $media_html = presscore_get_images_list($attachments_data, $open_thumbnail_in_lightbox); break; default: // slideshow dimensions $slider_proportions = get_post_meta($post->ID, '_dt_project_media_options_slider_proportions', true); $slider_proportions = wp_parse_args($slider_proportions, array('width' => '', 'height' => '')); $width = $slider_proportions['width']; $height = $slider_proportions['height']; $media_html = presscore_get_royal_slider($attachments_data, array('class' => array('slider-post'), 'width' => $width, 'height' => $height, 'style' => ' style="width: 100%;"')); } } else { $one_image_params = array(); if (!$open_thumbnail_in_lightbox) {
foreach ($gallery['src'] as $image_src) { $attachments_data[] = array('full' => $image_src, 'width' => 150, 'height' => 150, 'alt' => '', 'title' => '', 'description' => '', 'ID' => false); } } else { $attachments_data = array(); } } $class = array('alignnone'); $config = presscore_get_config(); if ('normal' == $config->get('post.preview.width')) { $class = array('alignleft'); } switch ($config->get('post.preview.gallery.style')) { case 'slideshow': $class[] = 'slider-simple'; echo '<div class="post-slider">'; echo presscore_get_post_media_slider($attachments_data, array('class' => $class, 'style' => ' style="width: 100%;"', 'proportions' => $config->get('post.preview.gallery.sideshow.proportions'))); echo '</div>'; break; case 'hovered_gallery': $class[] = 'rollover'; $gallery_args = array('class' => $class, 'style' => ''); echo presscore_get_images_gallery_hoovered(current($attachments_data), $attachments_data, $gallery_args); break; default: if ('normal' == $config->get('post.preview.width')) { $class[] = 'format-gallery-normal'; } // show only 9 images echo presscore_get_images_gallery_1($attachments_data, array('class' => $class, 'style' => '', 'show_only' => 9)); }