function blox_parse_video_hook($atts, $content = null) { extract(shortcode_atts(array('title' => '', 'image' => '', 'color' => '#3a87ad', 'animation' => '', 'extra_class' => '', 'visibility' => ''), $atts)); $title = $title != '' ? '<h3 class="element-title">' . $title . '</h3>' : ''; $visibility = str_replace(',', ' ', $visibility); $extra_class = $extra_class . ' ' . $visibility; $result = ''; if (validateURL($content)) { if (wp_oembed_get($content) !== false) { return "<div class='blox-element video video_embed {$extra_class}'>" . $title . wp_oembed_get($content) . "</div>"; } else { return get_video_player(array('url' => $content, 'title' => $title, 'poster' => $image, 'color' => $color, 'extra_class' => $extra_class)); } } else { return "<div class='blox-element video video_embed {$extra_class}'>" . $title . $content . "</div>"; } return $result; }
function blox_format_video() { global $post; $video_content = get_post_meta($post->ID, '_format_video_embed', true); if ($video_content == '') { return ''; } $html = ''; $html .= '<div class="entry-media">'; $embedCheck = array("<embed", "<video", "<ifram", "<objec"); // only checking against the first 6 $firstSix = substr($video_content, 0, 6); // get the first 6 char if (validateURL($video_content)) { $oembed = wp_oembed_get($video_content, array()); if ($oembed !== false) { // Embed convertion $html .= $oembed; } else { $fimage = ''; if (has_post_thumbnail(get_the_ID())) { $image = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), 'blog'); $fimage = $image[0]; } // Seems self hosted video $html .= get_video_player(array('url' => $video_content, 'poster' => $fimage)); } } else { if (in_array($firstSix, $embedCheck)) { $html .= $video_content; } } $html .= '</div><!-- .entry-media -->'; return $html; }
function get_video($options) { global $post; $featured_image = ''; if (has_post_thumbnail(get_the_ID())) { $image = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), 'blog'); $featured_image = $image[0]; } $options = array_merge(array('video' => '', 'poster' => $featured_image), $options); if (validateURL($options['video'])) { $oembed = wp_oembed_get($options['video'], array()); if ($oembed !== false) { return $oembed; } else { return get_video_player(array('url' => $options['video'], 'poster' => $options['poster'])); } } else { return $options['video']; } }