Example #1
0
 /**
  * Hoovered gallery.
  *
  * @param array $attachments_data Attachments data array.
  * @param array $options Gallery options.
  *
  * @return string HTML.
  */
 function presscore_get_images_gallery_hoovered($attachments_data, $options = array())
 {
     if (empty($attachments_data)) {
         return '';
     }
     // clear attachments_data
     foreach ($attachments_data as $index => $data) {
         if (empty($data['full'])) {
             unset($attachments_data[$index]);
         }
     }
     unset($data);
     if (empty($attachments_data)) {
         return '';
     }
     static $gallery_counter = 0;
     $gallery_counter++;
     $id_mark_prefix = 'pp-gallery-hoovered-media-content-' . $gallery_counter . '-';
     $default_options = array('echo' => false, 'class' => array(), 'links_rel' => '', 'style' => '', 'share_buttons' => false, 'exclude_cover' => false, 'title_img_options' => array(), 'title_image_args' => array(), 'attachments_count' => null, 'show_preview_on_hover' => true, 'video_icon' => true);
     $options = wp_parse_args($options, $default_options);
     $class = implode(' ', (array) $options['class']);
     $small_images = array_slice($attachments_data, 1);
     $big_image = current($attachments_data);
     if (!is_array($options['attachments_count']) || count($options['attachments_count']) < 2) {
         $attachments_count = presscore_get_attachments_data_count($options['exclude_cover'] ? $small_images : $attachments_data);
     } else {
         $attachments_count = $options['attachments_count'];
     }
     list($images_count, $videos_count) = $attachments_count;
     $count_text = array();
     if ($images_count) {
         $count_text[] = sprintf(_n('1 image', '%s images', $images_count, LANGUAGE_ZONE), $images_count);
     }
     if ($videos_count) {
         $count_text[] = sprintf(__('%s video', LANGUAGE_ZONE), $videos_count);
     }
     $count_text = implode(',&nbsp;', $count_text);
     $image_args = array('img_class' => 'preload-me', 'class' => $class, 'custom' => implode(' ', array($options['links_rel'], $options['style'])), 'echo' => false);
     $image_hover = '';
     $mini_count = 3;
     $html = '';
     $share_buttons = '';
     if ($options['share_buttons']) {
         $share_buttons = presscore_get_share_buttons_for_prettyphoto('photo');
     }
     // medium images
     if (!empty($small_images)) {
         $html .= '<div class="dt-gallery-container mfp-hide"' . $share_buttons . '>';
         foreach ($attachments_data as $key => $data) {
             if ($options['exclude_cover'] && 0 == $key) {
                 continue;
             }
             $small_image_args = array('img_meta' => $data['thumbnail'], 'img_id' => empty($data['ID']) ? $data['ID'] : 0, 'alt' => $data['title'], 'title' => $data['description'], 'href' => esc_url($data['full']), 'custom' => '', 'class' => 'mfp-image');
             if ($options['share_buttons']) {
                 $small_image_args['custom'] = 'data-dt-location="' . esc_attr($data['permalink']) . '" ';
             }
             $mini_image_args = array('img_meta' => $data['thumbnail'], 'img_id' => empty($data['ID']) ? $data['ID'] : 0, 'alt' => $data['title'], 'title' => $data['description'], 'wrap' => '<img %IMG_CLASS% %SRC% %ALT% %IMG_TITLE% width="90" />');
             if ($mini_count && !(!$options['exclude_cover'] && 0 == $key) && $options['show_preview_on_hover']) {
                 $image_hover = '<span class="r-thumbn-' . $mini_count . '">' . dt_get_thumb_img(array_merge($image_args, $mini_image_args)) . '<i>' . $count_text . '</i></span>' . $image_hover;
                 $mini_count--;
             }
             if (!empty($data['video_url'])) {
                 $small_image_args['href'] = $data['video_url'];
                 $small_image_args['class'] = 'mfp-iframe';
             }
             $html .= sprintf('<a href="%s" title="%s" class="%s" data-dt-img-description="%s" %s></a>', esc_url($small_image_args['href']), esc_attr($small_image_args['alt']), esc_attr($small_image_args['class'] . ' dt-mfp-item'), esc_attr($small_image_args['title']), $small_image_args['custom']);
         }
         $html .= '</div>';
     }
     unset($image);
     if ($image_hover && $options['show_preview_on_hover']) {
         $image_hover = '<span class="rollover-thumbnails">' . $image_hover . '</span>';
     }
     // big image
     $big_image_args = array('img_meta' => array($big_image['full'], $big_image['width'], $big_image['height']), 'img_id' => empty($big_image['ID']) ? $big_image['ID'] : 0, 'wrap' => '<a %HREF% %CLASS% %CUSTOM% %IMG_TITLE%><img %SRC% %IMG_CLASS% %ALT% %IMG_TITLE% %SIZE% />' . $image_hover . '</a>', 'alt' => $big_image['alt'], 'title' => $big_image['title'], 'class' => $class, 'options' => $options['title_img_options']);
     if (empty($small_images)) {
         $big_image_args['custom'] = ' data-dt-img-description="' . esc_attr($big_image['description']) . '"' . $share_buttons;
         if ($options['share_buttons']) {
             $big_image_args['custom'] = ' data-dt-location="' . esc_attr($big_image['permalink']) . '"' . $big_image_args['custom'];
         }
         $big_image_args['class'] .= ' dt-single-mfp-popup dt-mfp-item mfp-image';
     } else {
         $big_image_args['custom'] = $image_args['custom'];
         $big_image_args['class'] .= ' dt-gallery-mfp-popup';
     }
     $big_image_args = apply_filters('presscore_get_images_gallery_hoovered-title_img_args', $big_image_args, $image_args, $options, $big_image);
     if ($options['video_icon'] && !empty($big_image['video_url']) && !$options['exclude_cover']) {
         $big_image_args['href'] = $big_image['video_url'];
         $blank_image = presscore_get_blank_image();
         $video_link_classes = 'video-icon';
         if (empty($small_images)) {
             $video_link_classes .= ' mfp-iframe dt-single-mfp-popup dt-mfp-item';
         } else {
             $video_link_classes .= ' dt-gallery-mfp-popup';
         }
         $video_link_custom = $big_image_args['custom'];
         $big_image_args['class'] = str_replace(array('rollover', 'mfp-image'), array('rollover-video', ''), $class);
         $big_image_args['custom'] = $options['style'];
         $big_image_args['wrap'] = '<div %CLASS% %CUSTOM%><img %IMG_CLASS% %SRC% %ALT% %IMG_TITLE% %SIZE% /><a %HREF% %IMG_TITLE% class="' . $video_link_classes . '"' . $video_link_custom . '></a></div>';
     }
     $image = dt_get_thumb_img(array_merge($image_args, $big_image_args, $options['title_image_args']));
     $html = $image . $html;
     return $html;
 }
Example #2
0
if ($media_items && $is_pass_protected) {
    $media_items = array($media_items[0]);
}
// get attachments data
$attachments_data = presscore_get_attachment_post_data($media_items);
// if there are one image in gallery
if (count($attachments_data) == 1) {
    $class[] = 'rollover-zoom';
    $exclude_cover = false;
}
if (!$desc_on_hover) {
    $class[] = 'alignnone';
}
$post_title = '<a href="" class="dt-trigger-first-mfp">' . $post_title . '</a>';
// count attachments
$attachments_count = presscore_get_attachments_data_count(has_post_thumbnail() && $exclude_cover ? array_slice($attachments_data, 1) : $attachments_data);
list($images_count, $videos_count) = $attachments_count;
// if we have content to show and description on hover anabled
if ($show_content && $desc_on_hover || $is_new_hover) {
    $image_hover = '';
    $before_content = '<div class="rollover-project' . (!$show_content ? ' rollover-project-empty' : '') . '">';
    $after_content = '</div>';
    if (in_array($description, array('on_hoover', 'on_dark_gradient', 'from_bottom'))) {
        $before_description = '<div class="rollover-content">';
        $after_description = '</div>';
    } else {
        if ('on_hoover_centered' == $description) {
            $before_description = '<div class="rollover-content"><div class="wf-table"><div class="wf-td">';
            $after_description = '</div></div></div>';
        }
    }