Exemplo n.º 1
0
 function ew_img_video($atts)
 {
     extract(shortcode_atts(array('src_thumb' => '', 'src_zoom_img' => '', 'link_video' => '', 'width_thumb' => '190', 'height_thumb' => '103', 'type' => '', 'use_lightbox' => 'true', 'custom_link' => '#', 'class' => '', 'title' => ''), $atts));
     $width_div = $width_thumb + 8;
     $height_div = $height_thumb + 8;
     $left_fancy = floor(($width_div - 30) / 2);
     $top_fancy = floor(($height_div - 30) / 2);
     $result = "<div class='image-style {$class}' style='width:{$width_div}px;height:{$height_div}px'>";
     if ($type == 'video') {
         if ($link_video) {
             if (strstr($link_video, 'youtube.com') || strstr($link_video, 'youtu.be')) {
                 $class_fancy = ' youtube';
                 $big_video_url = 'http://www.youtube.com/watch?v=' . wp_parse_youtube_link($link_video);
             } else {
                 $class_fancy = 'vimeo';
                 $big_video_url = $link_video;
             }
             $result .= "<a class='thumbnail' href='" . $custom_link . "' style='width:{$width_thumb}px;height:{$height_thumb}px'>" . get_thumbnail_video($link_video, $width_thumb, $height_thumb) . "</a>";
             if ($use_lightbox == 'true') {
                 $result .= "<div class='fancybox_container' style='display:none;' id='img-video-" . rand(0, 1000) . "{$width_thumb}{$height_thumb}'>\n\t\t\t\t\t\t\t<a title='{$title}' class='fancybox_control {$class_fancy}' href='{$big_video_url}' style='left:{$left_fancy}px;top:{$top_fancy}px'>Lightbox</a>\n\t\t\t\t\t\t</div>";
             }
         }
     } else {
         if ($src_thumb) {
             $result .= "<a href='{$custom_link}' class='thumbnail' style='width:{$width_thumb}px;height:{$height_thumb}px'><img width='{$width_thumb}' height='{$height_thumb}' src='{$src_thumb}'/></a>";
         }
         if ($src_zoom_img && $use_lightbox == 'true') {
             $result .= "<div class='fancybox_container' style='display:none;' id='img-video-" . rand(0, 1000) . "{$width_thumb}{$height_thumb}'>\n\t\t\t\t\t\t<a title='{$title}' class='fancybox_control' href='{$src_zoom_img}' style='left:{$left_fancy}px;top:{$top_fancy}px'>Lightbox</a>\n\t\t\t\t\t</div>";
         }
     }
     $result .= "</div>";
     return $result;
 }
Exemplo n.º 2
0
 function ew_lightbox($atts)
 {
     extract(shortcode_atts(array('href' => '', 'title' => 'Lightbox', 'group' => '', 'photo' => '', 'lb_with' => 'text', 'use_iframe' => 'false', 'width' => 150, 'height' => 150, 'button_text' => __('Lightbox Button', 'wpdance')), $atts));
     $rel = !empty($group) ? " rel='{$group}'" : '';
     $iframe_class = $use_iframe == 'true' ? " iframe" : '';
     // Parse href for youtube, vimeo or image
     if (strstr($href, 'youtube.com') || strstr($href, 'youtu.be')) {
         $class_fancy = ' youtube';
         if (wp_parse_youtube_link($href)) {
             $big_url = 'http://www.youtube.com/watch?v=' . wp_parse_youtube_link($href);
         } else {
             $big_url = $href;
         }
     } elseif (strstr($href, 'vimeo.com')) {
         $class_fancy = ' vimeo';
         $big_url = $href;
     } else {
         $class_fancy = '';
         $big_url = $href;
     }
     if ($use_iframe == 'true') {
         $class_fancy = '';
     }
     if ($lb_with == 'text') {
         return "<a class='lb_control{$class_fancy}{$iframe_class}' href='{$big_url}'{$rel} title='{$title}'>{$title}</a>";
     } elseif ($lb_with == 'img') {
         if ($photo) {
             return "<a class='lb_control{$class_fancy}{$iframe_class}' href='{$big_url}'{$rel} title='{$title}'><img src='{$photo}'/></a>";
         } else {
             return "<a class='lb_control{$class_fancy}{$iframe_class}' href='{$big_url}'{$rel} title='{$title}'>" . get_thumbnail_video($href, $width, $height) . "</a>";
         }
     } elseif ($lb_with == 'button') {
         return "<a class='btn_lightbox lb_control{$class_fancy}{$iframe_class}' href='{$big_url}'{$rel} title='{$title}'><span><span>" . $button_text . "</span></span></a>";
     }
 }
    function show_light_box($post, $class_fancy, $rel = '', $id = '', $begin_show = false)
    {
        // Get link lightbox for image or video (youtube or vimeo)
        if ($video_link = get_post_meta($post->ID, THEME_SLUG . 'video_portfolio', true)) {
            $thumbnail = get_thumbnail_video($video_link, $width_thumb, $height_thumb);
            if (strstr($video_link, 'youtube.com') || strstr($video_link, 'youtu.be')) {
                $class_fancy .= ' youtube';
                $big_image_url = 'http://www.youtube.com/watch?v=' . wp_parse_youtube_link($video_link);
            } else {
                $class_fancy .= ' vimeo';
                $big_image_url = $video_link;
            }
        } else {
            $big_image_id = get_post_thumbnail_id($post->ID);
            $big_image_url = wp_get_attachment_image_src($big_image_id, 'full');
            $big_image_url = $big_image_url[0];
        }
        ?>
		<div class="fancybox_container"<?php 
        if ($id) {
            echo " id='{$id}'";
        }
        if (!$begin_show) {
            echo " style='display:none'";
        }
        ?>
>
			<a class="<?php 
        echo $class_fancy;
        ?>
 fancybox_control" title="<?php 
        echo get_the_title($post->ID);
        ?>
" <?php 
        if ($rel) {
            echo "rel='{$rel}'";
        }
        ?>
 href="<?php 
        echo $big_image_url;
        ?>
"><?php 
        _e('LightBox', 'wpdance');
        ?>
</a>
		</div>	
		<?php 
    }