/**
  * Porthole slider data.
  *
  */
 function presscore_render_porthole_slider_data()
 {
     global $post;
     $config = Presscore_Config::get_instance();
     $slider_id = $config->get('slideshow_sliders');
     $slideshows = presscore_query()->get_posts(array('post_type' => 'dt_slideshow', 'post__in' => $slider_id, 'has_password' => false));
     if (!$slideshows || !$slideshows->have_posts()) {
         return;
     }
     $slides = array();
     foreach ($slideshows->posts as $slideshow) {
         $media_items = get_post_meta($slideshow->ID, '_dt_slider_media_items', true);
         if (empty($media_items)) {
             continue;
         }
         $slides = array_merge($slides, $media_items);
     }
     $slides = array_unique($slides);
     $media_query = presscore_query()->get_attachments(array('posts_per_page' => -1, 'orderby' => 'post__in', 'post__in' => $slides));
     // prepare data
     if ($media_query->have_posts()) {
         echo '<ul id="main-slideshow-content" class="royalSlider rsHomePorthole">';
         while ($media_query->have_posts()) {
             $media_query->the_post();
             $video_url = get_post_meta($post->ID, 'dt-video-url', true);
             $img_link = get_post_meta($post->ID, 'dt-img-link', true);
             $thumb_meta = wp_get_attachment_image_src($post->ID, 'thumbnail');
             $hide_title = presscore_imagee_title_is_hidden($post->ID);
             $img_custom = 'data-rsTmb="' . $thumb_meta[0] . '"';
             if ($video_url) {
                 $img_custom .= ' data-rsVideo="' . esc_url($video_url) . '"';
             }
             $img_args = array('img_meta' => wp_get_attachment_image_src($post->ID, 'full'), 'img_id' => $post->ID, 'img_class' => 'rsImg', 'custom' => $img_custom, 'echo' => false, 'wrap' => '<img %IMG_CLASS% %SRC% %CUSTOM% %ALT% %SIZE% />');
             $image = dt_get_thumb_img($img_args);
             $caption = '';
             if (!$config->get('slideshow_hide_captions')) {
                 if (!$hide_title && ($title = get_the_title())) {
                     $caption .= '<div class="rsTitle">' . $title . '</div>';
                 }
                 if ($content = get_the_content()) {
                     $caption .= '<div class="rsDesc">' . $content . '</div>';
                 }
                 if ($caption) {
                     $caption = sprintf('<figure class="rsCapt rsABlock">%s</figure>', $caption);
                 }
                 if ($img_link) {
                     $caption = sprintf('<a class="rsCLink" href="%s"><span class="assistive-text">%s</span></a>', esc_url($img_link), __('details', 'the7mk2')) . $caption;
                 }
             }
             printf('<li>%s</li>', $image . $caption);
         }
         wp_reset_postdata();
         echo '</ul>';
     }
 }
예제 #2
0
 /**
  * Get related posts attachments data slightly modified.
  *
  * @return array Attachments data.
  */
 function presscore_get_related_posts($options = array())
 {
     $default_options = array('select' => 'only', 'exclude_current' => true, 'args' => array());
     $options = wp_parse_args($options, $default_options);
     // exclude current post if in the loop
     if (in_the_loop() && $options['exclude_current']) {
         $options['args'] = array_merge($options['args'], array('post__not_in' => array(get_the_ID())));
     }
     $posts = presscore_get_posts_in_categories($options);
     update_post_thumbnail_cache($posts);
     $attachments_ids = array();
     $attachments_data_override = array();
     $posts_data = array();
     // get posts attachments id
     if ($posts->have_posts()) {
         global $post;
         $post_back = $post;
         while ($posts->have_posts()) {
             $posts->the_post();
             // thumbnail or first attachment id
             if (has_post_thumbnail()) {
                 $attachment_id = get_post_thumbnail_id();
             } else {
                 if ($attachment = presscore_get_first_image()) {
                     $attachment_id = $attachment->ID;
                 } else {
                     $attachment_id = 0;
                 }
             }
             switch (get_post_type()) {
                 case 'post':
                     $post_meta = presscore_new_posted_on('post');
                     break;
                 case 'dt_portfolio':
                     $post_meta = presscore_new_posted_on('dt_portfolio');
                     break;
                 default:
                     $post_meta = presscore_new_posted_on();
             }
             $post_data = array();
             /////////////////////////
             // attachment data //
             /////////////////////////
             $post_data['full'] = $post_data['width'] = $post_data['height'] = '';
             $meta = wp_get_attachment_image_src($attachment_id, 'full');
             if (!empty($meta)) {
                 $post_data['full'] = esc_url($meta[0]);
                 $post_data['width'] = absint($meta[1]);
                 $post_data['height'] = absint($meta[2]);
             }
             $post_data['thumbnail'] = wp_get_attachment_image_src($attachment_id, 'thumbnail');
             $post_data['caption'] = '';
             $post_data['video_url'] = esc_url(get_post_meta($attachment_id, 'dt-video-url', true));
             $post_data['mime_type_full'] = get_post_mime_type($attachment_id);
             $post_data['mime_type'] = dt_get_short_post_myme_type($attachment_id);
             $post_data['ID'] = $attachment_id;
             $post_data['image_attachment_data'] = array('caption' => $post_data['caption'], 'description' => wp_kses_post(get_post_field('post_content', $attachment_id)), 'title' => presscore_imagee_title_is_hidden($attachment_id) ? '' : get_the_title($attachment_id), 'permalink' => get_permalink($attachment_id), 'video_url' => $post_data['video_url'], 'ID' => $attachment_id);
             ///////////////////
             // post data //
             ///////////////////
             $post_data['title'] = get_the_title();
             $post_data['permalink'] = get_permalink();
             $post_data['link'] = presscore_get_project_link('project-link');
             $post_data['description'] = get_the_excerpt();
             $post_data['alt'] = get_the_title();
             $post_data['parent_id'] = get_the_ID();
             $post_data['meta'] = $post_meta;
             // save data
             $posts_data[] = $post_data;
         }
         $post = $post_back;
         setup_postdata($post);
     }
     return $posts_data;
 }
예제 #3
0
 function presscore_get_project_rollover_zoom_icon($args = array())
 {
     $default_args = array('popup' => 'single', 'class' => '', 'attachment_id' => 0);
     $args = wp_parse_args($args, $default_args);
     $config = presscore_get_config();
     $rollover_icon = '';
     if ($config->get('show_zoom') && $args['attachment_id']) {
         $attachment_id = absint($args['attachment_id']);
         if (!presscore_imagee_title_is_hidden($attachment_id)) {
             $attachment_title = get_post_field('post_title', $attachment_id);
         } else {
             $attachment_title = '';
         }
         $link_class = array('project-zoom', 'dt-mfp-item');
         if ($args['class']) {
             $link_class[] = $args['class'];
         }
         switch ($args['popup']) {
             case 'single':
                 $link_class[] = 'dt-single-mfp-popup';
                 break;
             case 'gallery':
                 $link_class[] = 'dt-gallery-mfp-popup';
                 break;
             case 'first':
                 $link_class[] = 'dt-first-mfp-popup';
                 break;
         }
         $attachment_video_src = get_post_meta($attachment_id, 'dt-video-url', true);
         if ($attachment_video_src) {
             $link_class[] = 'mfp-iframe';
             $link_src = $attachment_video_src;
         } else {
             $attachment_src = wp_get_attachment_image_src($attachment_id, 'full');
             $link_class[] = 'mfp-image';
             $link_src = $attachment_src[0];
         }
         $attachment_description = get_post_field('post_content', $attachment_id);
         $rollover_icon = sprintf('<a href="%s" class="%s" title="%s" data-dt-img-description="%s">%s</a>', esc_url($link_src), esc_attr(implode(' ', $link_class)), esc_attr($attachment_title), esc_attr($attachment_description), __('Zoom', LANGUAGE_ZONE));
     }
     return $rollover_icon;
 }
예제 #4
0
<article <?php 
post_class('post');
?>
>

		<?php 
$media = '';
$is_pass_protected = post_password_required();
if (!$is_pass_protected || $desc_on_hover) {
    if ('slideshow' != $previw_type || $desc_on_hover) {
        if (has_post_thumbnail()) {
            $thumb_id = get_post_thumbnail_id();
            $thumb_meta = wp_get_attachment_image_src($thumb_id, 'full');
            $attachment_post = get_post($thumb_id);
            $video_url = esc_url(get_post_meta($thumb_id, 'dt-video-url', true));
            $hide_title = presscore_imagee_title_is_hidden($thumb_id);
            $zoom_link = sprintf('<a href="%s" class="project-zoom dt-single-mfp-popup dt-mfp-item %s" title="%s" data-dt-img-description="%s">%s</a>', $video_url ? esc_url($video_url) : esc_url($thumb_meta[0]), ($video_url ? 'mfp-iframe' : 'mfp-image') . ('under_image' == $description ? ' btn-zoom' : ''), $hide_title ? '' : esc_attr($attachment_post->post_title), esc_attr($attachment_post->post_content), __('Zoom', LANGUAGE_ZONE));
        } else {
            $thumb_id = 0;
            $thumb_meta = presscore_get_default_image();
        }
        $thumb_args = array('img_meta' => $thumb_meta, 'img_id' => $thumb_id, 'img_class' => 'preload-me', 'class' => $link_classes, 'href' => get_permalink($post->ID), 'echo' => false);
        $thumb_args['wrap'] = '<a %HREF% %CLASS% %TITLE% %CUSTOM%><img %IMG_CLASS% %SRC% %ALT% %SIZE% /></a>';
        if ($video_url && $show_video_hoover) {
            $thumb_args['class'] = 'alignnone rollover';
            $thumb_args['wrap'] = '<div %CLASS% %CUSTOM%><img %IMG_CLASS% %SRC% %ALT% %IMG_TITLE% %SIZE% /><a %HREF% class="video-icon"></a></div>';
        }
        if ($config->get('justified_grid')) {
            $thumb_args['options'] = array('h' => round($config->get('target_height') * 1.3), 'z' => 0);
        } else {
            if ('wide' == $post_preview && !$config->get('all_the_same_width')) {
 /**
  * Add description to images.
  *
  * TODO: use proper image attributes i.e. img_title and alt. Change all images wraps.
  */
 function presscore_add_default_meta_to_images($args = array())
 {
     // add description to images if it's not defined
     if ($id = absint($args['img_id'])) {
         $attachment = get_post($id);
         if ($attachment) {
             if ('' === $args['title']) {
                 $args['title'] = esc_attr($attachment->post_title);
             }
             // set image description
             if (empty($args['img_description'])) {
                 $args['img_description'] = $attachment->post_content;
             }
         }
         $hide_title = presscore_imagee_title_is_hidden($id);
         // use image title instead alt
         if ($hide_title) {
             // $args['alt'] = get_the_title( $id );
             // } else {
             $args['img_title'] = false;
         }
     }
     return $args;
 }
 /**
  * Render slideshow.
  *
  * @param  array $attachments
  * @param  array $atts
  * @param  integer $instance
  * @param  string $id
  * @return string
  */
 protected function slideshow($attachments, $atts, $instance, $id)
 {
     $output = "\n";
     $dimensions = '';
     if ($atts['width']) {
         $dimensions .= sprintf(' data-width="%d"', absint($atts['width']));
     }
     if ($atts['height']) {
         $dimensions .= sprintf(' data-height="%d"', absint($atts['height']));
     }
     $output .= "<ul class='slider-simple royalSlider rsShor galleryid-{$id}' style='width: 100%;'{$dimensions}>\n";
     foreach ($attachments as $id => $attachment) {
         $alt = trim(strip_tags(get_post_meta($id, '_wp_attachment_image_alt', true)));
         // Use Alt field first
         if (!$alt) {
             $alt = trim(strip_tags($attachment->post_excerpt));
             // If not, Use the Caption
         }
         if (!$alt) {
             $alt = trim(strip_tags($attachment->post_title));
             // Finally, use the title
         }
         $image_args = array('wrap' => '<img %IMG_CLASS% %SRC% %SIZE% %ALT% %CUSTOM% />', 'img_id' => $id, 'alt' => $alt, 'title' => trim(strip_tags($attachment->post_title)), 'img_class' => 'rsImg', 'class' => '', 'custom' => '', 'echo' => false);
         $image_video_url = esc_url(get_post_meta($id, 'dt-video-url', true));
         if ($image_video_url) {
             $image_video_url = remove_query_arg(array('iframe', 'width', 'height'), $image_video_url);
             $image_args['custom'] = "data-rsVideo='{$image_video_url}'";
             $output .= "<li class='rollover-video'>\n";
         } else {
             $output .= "<li>\n";
         }
         $output .= dt_get_thumb_img($image_args) . "\n";
         $image_link = esc_url(get_post_meta($id, 'dt-img-link', true));
         if ($image_link) {
             $output .= "<a href='{$image_link}' class='rsCLink' target='_blank'></a>\n";
         }
         $caption_html = '';
         if (!presscore_imagee_title_is_hidden($id) && $attachment->post_title) {
             $caption_html .= "<h4>" . esc_html($attachment->post_title) . "</h4>\n";
         }
         if ($attachment->post_content) {
             $caption_html .= wpautop($attachment->post_content);
         }
         if ($caption_html) {
             $output .= "<div class='slider-post-caption'>\n<div class='slider-post-inner'>{$caption_html}</div>\n</div>\n";
         }
         $output .= "</li>\n";
     }
     $output .= "</ul>\n";
     return $output;
 }
예제 #7
0
 /**
  * Filter attachment data.
  *
  * @since 3.1
  */
 function presscore_filter_attachment_data($attachment_data = array())
 {
     // hide title
     if (!empty($attachment_data['ID'])) {
         $hide_title = presscore_imagee_title_is_hidden($attachment_data['ID']);
         if ($hide_title) {
             $attachment_data['title'] = '';
         }
     }
     $attachment_data['image_attachment_data'] = array('alt' => $attachment_data['alt'], 'caption' => $attachment_data['caption'], 'description' => $attachment_data['description'], 'title' => $attachment_data['title'], 'permalink' => $attachment_data['permalink'], 'video_url' => $attachment_data['video_url'], 'ID' => $attachment_data['ID']);
     return $attachment_data;
 }