Example #1
0
function vimeo($atts, $content = null)
{
    extract(shortcode_atts(array('id' => ''), $atts));
    $VideoInfo = getVimeoInfo($id);
    $thumbnail = $VideoInfo['thumbnail_large'];
    $title = $VideoInfo['title'];
    $url = $VideoInfo['url'];
    return '<dl class="gallery-item">
			<dt class="gallery-icon vimeo">
				<a href="' . $url . '" title="' . $title . '" rel="prettyPhoto">
					<img width="300" height="200" src="' . $thumbnail . '" alt="' . $title . '" />
				</a>
			</dt>
			<dd class="gallery-caption" style="opacity: 1; ">
				' . truncate($title, 20) . '
			</dd>
		</dl>';
}
Example #2
0
        }
    } else {
        if (@$record['photo_url']) {
            $imgLocation = $record['photo_url'];
            $imgUrl = $record['photo_url'];
            $imgType = '';
            $imgTitle = $record['title'];
        } else {
            if (@$record['youtube_video_id']) {
                $imgLocation = 'http://img.youtube.com/vi/' . $record['youtube_video_id'] . '/mqdefault.jpg';
                $imgUrl = 'http://www.youtube.com/?v=' . $record['youtube_video_id'];
                $imgType = ' class="mfp-iframe"';
                $imgTitle = '';
            } else {
                if (@$record['vimeo_video_id']) {
                    $imgLocation = getVimeoInfo($record['vimeo_video_id']);
                    $imgUrl = 'http://www.vimeo.com/' . $record['vimeo_video_id'];
                    $imgType = ' class="mfp-iframe"';
                    $imgTitle = '';
                } else {
                    continue;
                }
            }
        }
    }
    ?>
						<div class="media-post">
							<a href="<?php 
    echo $imgUrl;
    ?>
"<?php 
Example #3
0
 function colabs_get_video_image($embed)
 {
     $video_thumb = '';
     // YouTube - get the video code if this is an embed code (old embed)
     preg_match('/youtube\\.com\\/v\\/([\\w\\-]+)/', $embed, $old_embed);
     // YouTube - if old embed returned an empty ID, try capuring the ID from the new iframe embed
     if (!isset($old_embed[1])) {
         preg_match('/youtube\\.com\\/embed\\/([\\w\\-]+)/', $embed, $iframe);
         if (isset($iframe[1])) {
             $youtube_img = $iframe[1];
         } else {
             // YouTube - if it is not an embed code, get the video code from the youtube URL
             preg_match('/v\\=(.+)&/', $embed, $youtube_url);
             if (isset($youtube_url[1])) {
                 $youtube_img = $youtube_url[1];
             }
         }
         if (isset($youtube_img)) {
             $video_thumb = "http://img.youtube.com/vi/" . $youtube_img . "/0.jpg";
         }
     }
     // Vimeo Thumbnail
     if (isset($video_thumb)) {
         preg_match('/vimeo\\.com\\/video\\/([\\w\\-]+)/', $embed, $vimeo_src);
         if (isset($vimeo_src[1])) {
             $vimeo = getVimeoInfo($vimeo_src[1], 'thumbnail_large');
             if (isset($vimeo)) {
                 $video_thumb = $vimeo;
             }
         }
     }
     // Metacafe Thumbnail
     if (isset($video_thumb)) {
         preg_match('/metacafe\\.com\\/fplayer\\/([\\w\\-]+)/', $embed, $metacafe);
         if (isset($metacafe[1])) {
             $video_thumb = "http://s3.mcstatic.com/thumb/" . $metacafe[1] . ".jpg";
         }
     }
     // Dailymotion
     if (isset($video_thumb)) {
         preg_match('/dailymotion\\.com\\/embed\\/video\\/([\\w\\-]+)/', $embed, $daily);
         if (isset($daily[1])) {
             $daily_redirect = "http://www.dailymotion.com/thumbnail/video/" . $daily[1];
             $uri_api = wp_remote_retrieve_body(wp_remote_get('https://api.dailymotion.com/video/' . $daily[1] . '?fields=thumbnail_url', array('sslverify' => false)));
             $uri_api = json_decode($uri_api);
             $daily_thumb = $uri_api->thumbnail_url;
             $video_thumb = $daily_thumb;
         }
     }
     // return whichever thumbnail image you would like to retrieve
     return $video_thumb;
 }
Example #4
0
function get_video_thumbnail($post_id = null)
{
    // Get the post ID if none is provided
    if ($post_id == null or $post_id == '') {
        $post_id = get_the_ID();
    }
    // Check to see if thumbnail has already been found and still exists as a file
    if (($thumbnail_meta = get_post_meta($post_id, '_video_thumbnail', true)) != '' && wp_remote_retrieve_response_code(wp_remote_head($thumbnail_meta)) === '200') {
        return $thumbnail_meta;
    } else {
        // Gets the post's content
        $post_array = get_post($post_id);
        $markup = $post_array->post_content;
        $markup = apply_filters('the_content', $markup);
        $new_thumbnail = null;
        // Simple Video Embedder Compatibility
        if (function_exists('p75HasVideo')) {
            if (p75HasVideo($post_id)) {
                $markup = p75GetVideo($post_id);
            }
        }
        // Checks for the old standard YouTube embed
        preg_match('#<object[^>]+>.+?https?://www.youtube.com/[ve]/([A-Za-z0-9\\-_]+).+?</object>#s', $markup, $matches);
        // More comprehensive search for YouTube embed, redundant but necessary until more testing is completed
        if (!isset($matches[1])) {
            preg_match('#https?://www.youtube.com/[ve]/([A-Za-z0-9\\-_]+)#s', $markup, $matches);
        }
        // Checks for YouTube iframe, the new standard since at least 2011
        if (!isset($matches[1])) {
            preg_match('#https?://www.youtube.com/embed/([A-Za-z0-9\\-_]+)#s', $markup, $matches);
        }
        // Checks for any YouTube URL. After http(s) support a or v for Youtube Lyte and v or vh for Smart Youtube plugin
        if (!isset($matches[1])) {
            preg_match('#(?:https?(?:a|vh?)?://)?(?:www\\.)?youtube.com/watch\\?v=([A-Za-z0-9\\-_]+)#s', $markup, $matches);
        }
        // Checks for any shortened youtu.be URL. After http(s) a or v for Youtube Lyte and v or vh for Smart Youtube plugin
        if (!isset($matches[1])) {
            preg_match('#(?:https?(?:a|vh?)?://)?youtu.be/([A-Za-z0-9\\-_]+)#s', $markup, $matches);
        }
        // Checks for YouTube Lyte
        if (!isset($matches[1]) && function_exists('lyte_parse')) {
            preg_match('#<div class="lyte" id="([A-Za-z0-9\\-_]+)"#s', $markup, $matches);
        }
        // If we've found a YouTube video ID, create the thumbnail URL
        if (isset($matches[1])) {
            $youtube_thumbnail = 'http://img.youtube.com/vi/' . $matches[1] . '/0.jpg';
            // Check to make sure it's an actual thumbnail
            if (!function_exists('curl_init')) {
                $new_thumbnail = $youtube_thumbnail;
            } else {
                $ch = curl_init($youtube_thumbnail);
                curl_setopt($ch, CURLOPT_NOBODY, true);
                curl_exec($ch);
                $retcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
                // $retcode > 400 -> not found, $retcode = 200, found.
                curl_close($ch);
                if ($retcode == 200) {
                    $new_thumbnail = $youtube_thumbnail;
                }
            }
        }
        // Vimeo
        if ($new_thumbnail == null) {
            // Standard embed code
            preg_match('#<object[^>]+>.+?http://vimeo.com/moogaloop.swf\\?clip_id=([A-Za-z0-9\\-_]+)&.+?</object>#s', $markup, $matches);
            // Find Vimeo embedded with iframe code
            if (!isset($matches[1])) {
                preg_match('#http://player.vimeo.com/video/([0-9]+)#s', $markup, $matches);
            }
            // If we still haven't found anything, check for Vimeo embedded with JR_embed
            if (!isset($matches[1])) {
                preg_match('#\\[vimeo id=([A-Za-z0-9\\-_]+)]#s', $markup, $matches);
            }
            // If we still haven't found anything, check for Vimeo URL
            if (!isset($matches[1])) {
                preg_match('#(?:http://)?(?:www\\.)?vimeo.com/([A-Za-z0-9\\-_]+)#s', $markup, $matches);
            }
            // If we still haven't found anything, check for Vimeo shortcode
            if (!isset($matches[1])) {
                preg_match('#\\[vimeo clip_id="([A-Za-z0-9\\-_]+)"[^>]*]#s', $markup, $matches);
            }
            if (!isset($matches[1])) {
                preg_match('#\\[vimeo video_id="([A-Za-z0-9\\-_]+)"[^>]*]#s', $markup, $matches);
            }
            // Now if we've found a Vimeo ID, let's set the thumbnail URL
            if (isset($matches[1])) {
                $vimeo_thumbnail = getVimeoInfo($matches[1], $info = 'thumbnail_large');
                if (is_wp_error($vimeo_thumbnail)) {
                    return $vimeo_thumbnail;
                } else {
                    if (isset($vimeo_thumbnail)) {
                        $new_thumbnail = $vimeo_thumbnail;
                    }
                }
            }
        }
        // Blip.tv
        if ($new_thumbnail == null) {
            // Blip.tv embed URL
            preg_match('#http://blip.tv/play/([A-Za-z0-9]+)#s', $markup, $matches);
            // Now if we've found a Blip.tv embed URL, let's set the thumbnail URL
            if (isset($matches[1])) {
                $blip_thumbnail = getBliptvInfo($matches[1]);
                if (is_wp_error($blip_thumbnail)) {
                    return $blip_thumbnail;
                } else {
                    if (isset($blip_thumbnail)) {
                        $new_thumbnail = $blip_thumbnail;
                    }
                }
            }
        }
        // Justin.tv
        if ($new_thumbnail == null) {
            // Justin.tv archive ID
            preg_match('#archive_id=([0-9]+)#s', $markup, $matches);
            // Now if we've found a Justin.tv archive ID, let's set the thumbnail URL
            if (isset($matches[1])) {
                $justin_thumbnail = getJustintvInfo($matches[1]);
                $new_thumbnail = $justin_thumbnail;
            }
        }
        // Dailymotion
        if ($new_thumbnail == null) {
            // Dailymotion flash
            preg_match('#<object[^>]+>.+?http://www.dailymotion.com/swf/video/([A-Za-z0-9]+).+?</object>#s', $markup, $matches);
            // Dailymotion url
            if (!isset($matches[1])) {
                preg_match('#(?:https?://)?(?:www\\.)?dailymotion.com/video/([A-Za-z0-9]+)#s', $markup, $matches);
            }
            // Dailymotion iframe
            if (!isset($matches[1])) {
                preg_match('#https?://www.dailymotion.com/embed/video/([A-Za-z0-9]+)#s', $markup, $matches);
            }
            // Now if we've found a Dailymotion video ID, let's set the thumbnail URL
            if (isset($matches[1])) {
                $dailymotion_thumbnail = getDailyMotionThumbnail($matches[1]);
                if (is_wp_error($dailymotion_thumbnail)) {
                    return $dailymotion_thumbnail;
                } else {
                    if (isset($dailymotion_thumbnail)) {
                        $new_thumbnail = strtok($dailymotion_thumbnail, '?');
                    }
                }
            }
        }
        // Metacafe
        if ($new_thumbnail == null) {
            // Find ID from Metacafe embed url
            preg_match('#http://www.metacafe.com/fplayer/([A-Za-z0-9\\-_]+)/#s', $markup, $matches);
            // Now if we've found a Metacafe video ID, let's set the thumbnail URL
            if (isset($matches[1])) {
                $metacafe_thumbnail = getMetacafeThumbnail($matches[1]);
                if (is_wp_error($metacafe_thumbnail)) {
                    return $metacafe_thumbnail;
                } else {
                    if (isset($metacafe_thumbnail)) {
                        $new_thumbnail = strtok($metacafe_thumbnail, '?');
                    }
                }
            }
        }
        // Return the new thumbnail variable and update meta if one is found
        if ($new_thumbnail != null) {
            // Save as Attachment if enabled
            if (get_option('video_thumbnails_save_media') == 1) {
                $error = '';
                $ch = curl_init();
                $timeout = 0;
                curl_setopt($ch, CURLOPT_URL, $new_thumbnail);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
                curl_setopt($ch, CURLOPT_FAILONERROR, true);
                // Return an error for curl_error() processing if HTTP response code >= 400
                $image_contents = curl_exec($ch);
                if (curl_error($ch) != null || $image_contents == null) {
                    $curl_error = '';
                    if (curl_error($ch) != null) {
                        $curl_error = ": <code>" . curl_error($ch) . "</code>";
                    }
                    $error = new WP_Error('thumbnail_retrieval', __("Error retrieving a thumbnail from the URL <a href=\"" . $new_thumbnail . "\">" . $new_thumbnail . "</a>" . $curl_error . ". If opening that URL in your web browser shows an image, the problem may be related to your web server and might be something your server administrator can solve."));
                }
                curl_close($ch);
                if ($error != null) {
                    return $error;
                } else {
                    $upload = wp_upload_bits(basename($new_thumbnail), null, $image_contents);
                    $new_thumbnail = $upload['url'];
                    $filename = $upload['file'];
                    $wp_filetype = wp_check_filetype(basename($filename), null);
                    $attachment = array('post_mime_type' => $wp_filetype['type'], 'post_title' => get_the_title($post_id), 'post_content' => '', 'post_status' => 'inherit');
                    $attach_id = wp_insert_attachment($attachment, $filename, $post_id);
                    // you must first include the image.php file
                    // for the function wp_generate_attachment_metadata() to work
                    require_once ABSPATH . "wp-admin" . '/includes/image.php';
                    $attach_data = wp_generate_attachment_metadata($attach_id, $filename);
                    wp_update_attachment_metadata($attach_id, $attach_data);
                }
            }
            // Add hidden custom field with thumbnail URL
            if (!update_post_meta($post_id, '_video_thumbnail', $new_thumbnail)) {
                add_post_meta($post_id, '_video_thumbnail', $new_thumbnail, true);
            }
            // Set attachment as featured image if enabled
            if (get_option('video_thumbnails_set_featured') == 1 && get_option('video_thumbnails_save_media') == 1 && get_post_meta($post_id, '_thumbnail_id', true) == '') {
                if (!update_post_meta($post_id, '_thumbnail_id', $attach_id)) {
                    add_post_meta($post_id, '_thumbnail_id', $attach_id, true);
                }
            }
        }
        return $new_thumbnail;
    }
}
Example #5
0
var full=1
//configure background color:
var marqueebgcolor="#ffffff"
//Pause marquee onMousever (0=no. 1=yes)?
var pauseit=1
//Width of each thumbnail
var imgwidth="140px"

//Specify the marquee's content (don't delete <nobr> tag)
//Keep all content on ONE line, and backslash any single quotations (ie: that\'s great):

var marqueecontent='<nobr><a href="/videos/vimeo.php#animal_angels_documentary"><img src="<?php 
echo getVimeoInfo(16752583);
?>
" width="'+imgwidth+'" height="'+marqueeheight+'" alt="Short documentary on Animal Angels Foundation" title="Short documentary on Animal Angels Foundation"></a><img src="/images/reel-divider.jpg" width="10" height="'+marqueeheight+'"><a href="/videos/vimeo.php#animal_angels_action"><img src="<?php 
echo getVimeoInfo(11785976);
?>
" width="'+imgwidth+'" height="'+marqueeheight+'" alt="Our Angels in Action" title="Our Angels in Action"></a><img src="/images/reel-divider.jpg" width="10" height="'+marqueeheight+'"><a href="/videos/youtube.php"><img src="http://img.youtube.com/vi/MHBg5nfAjU4/0.jpg" alt="Animal Assisted Therapy with Children" title="Animal Assisted Therapy with Children" width="'+imgwidth+'" height="'+marqueeheight+'" /></a><img src="/images/reel-divider.jpg" width="10" height="'+marqueeheight+'"><a href="/videos/youtube.php"><img src="http://img.youtube.com/vi/JKQgxOCnGRs/0.jpg" alt="Animal Assisted Therapy with Adults" title="Animal Assisted Therapy with Adults" width="'+imgwidth+'" height="'+marqueeheight+'" /></a><img src="/images/reel-divider.jpg" width="10" height="'+marqueeheight+'"><a href="/videos/youtube.php"><img src="http://img.youtube.com/vi/Qzfyw67WHZM/0.jpg" alt="Animal Angels Foundation on YouTube" title="Animal Angels Foundation on YouTube" width="'+imgwidth+'" height="'+marqueeheight+'" /></a><img src="/images/reel-divider.jpg" width="10" height="'+marqueeheight+'"></nobr>'


////NO NEED TO EDIT BELOW THIS LINE////////////
var copyspeed=marqueespeed
var pausespeed=(pauseit==0)? copyspeed: 0
var iedom=document.all||document.getElementById
if (iedom)
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100px;left:-9000px">'+marqueecontent+'</span>')
var actualwidth=''
var cross_marquee, cross_marquee2, ns_marquee
function populate(){
if (iedom){
var initFill=(full==1)? '0px' : parseInt(marqueewidth)+0+"px"