Example #1
2
 function realistic_get_first_embed_video($post_id)
 {
     $post = get_post($post_id);
     $content = do_shortcode(apply_filters('the_content', $post->post_content));
     $embeds = get_media_embedded_in_content($content);
     if (!empty($embeds)) {
         //check what is the first embed containg video tag, youtube or vimeo
         foreach ($embeds as $embed) {
             if (strpos($embed, 'video') || strpos($embed, 'youtube') || strpos($embed, 'vimeo') || strpos($embed, 'dailymotion') || strpos($embed, 'vine') || strpos($embed, 'wordPress.tv') || strpos($embed, 'hulu')) {
                 return $embed;
             }
         }
     } else {
         //No video embedded found
         return;
     }
 }
Example #2
0
function bambule_get_embedded_media($type = array())
{
    $content = do_shortcode(apply_filters('the_content', get_the_content()));
    $embed = get_media_embedded_in_content($content, $type);
    if (in_array('audio', $type)) {
        $output = str_replace('?visual=true', '?visual=false', $embed[0]);
    } else {
        $output = $embed[0];
    }
    return $output;
}
/**
 * @param $post_id
 * @return bool
 */
function ods_get_first_embed_media($post_id)
{
    $post = get_post($post_id);
    $content = do_shortcode(apply_filters('the_content', $post->post_content));
    $embeds = get_media_embedded_in_content($content, array('object', 'embed', 'iframe'));
    if (!empty($embeds)) {
        return $embeds[0];
    } else {
        return false;
    }
}
Example #4
0
function get_first_embed_media($post_id)
{
    $post = get_post($post_id);
    $embeds = get_media_embedded_in_content($post->post_content);
    if (!empty($embeds)) {
        //return first embed
        return $embeds[0];
    } else {
        //No embeds found
        return false;
    }
}
function post_grid_first_embed_media($post_id)
{
    $post = get_post($post_id);
    $content = do_shortcode(apply_filters('the_content', $post->post_content));
    $embeds = get_media_embedded_in_content($content);
    if (!empty($embeds)) {
        //return first embed
        return $embeds[0];
    } else {
        //No embeds found
        return false;
    }
}
Example #6
0
/**
 * Load the Responsive videos plugin
 */
function jetpack_responsive_videos_init()
{
    /* If the doesn't theme support 'jetpack-responsive-videos', don't continue */
    if (!current_theme_supports('jetpack-responsive-videos')) {
        return;
    }
    /* If the theme does support 'jetpack-responsive-videos', wrap the videos */
    add_filter('wp_video_shortcode', 'jetpack_responsive_videos_embed_html');
    add_filter('video_embed_html', 'jetpack_responsive_videos_embed_html');
    /* Check to make sure the content is a video before applying to oEmbeds */
    if (!empty(get_media_embedded_in_content('video'))) {
        add_filter('embed_oembed_html', 'jetpack_responsive_videos_embed_html');
    }
    /* Wrap videos in Buddypress */
    add_filter('bp_embed_oembed_html', 'jetpack_responsive_videos_embed_html');
}
    echo '</div><!-- .entry-meta -->';
}
if (is_single()) {
    the_title('<h1 class="entry-title">', '</h1>');
} else {
    the_title('<h2 class="entry-title"><a href="' . esc_url(get_permalink()) . '" rel="bookmark">', '</a></h2>');
}
?>
	</header><!-- .entry-header -->

	<?php 
$content = apply_filters('the_content', get_the_content());
$audio = false;
// Only get audio from the content if a playlist isn't present.
if (false === strpos($content, 'wp-playlist-script')) {
    $audio = get_media_embedded_in_content($content, array('audio'));
}
?>

	<?php 
if ('' !== get_the_post_thumbnail() && !is_single()) {
    ?>
		<div class="post-thumbnail">
			<a href="<?php 
    the_permalink();
    ?>
">
				<?php 
    the_post_thumbnail('twentyseventeen-featured-image');
    ?>
			</a>
 /**
  * Retrieve audio related to a post.
  *
  * @since 3.1.0
  * @uses $wp_embed
  * @todo Consider using get_enclosed(), too?
  * @todo Add support for the Crowd Favorite dealio.
  *
  * @param  int|WP_Post Optional. Post ID or object. Defaults to the current post in the loop.
  * @return string      HTML <audio> tag or empty string.
  */
 public function get_audio($post = 0)
 {
     global $wp_embed;
     $return_false_on_fail = $wp_embed->return_false_on_fail;
     $wp_embed->return_false_on_fail = true;
     $html = '';
     $post = get_post($post);
     // Extract an [audio] shortcode from the post content.
     if (has_shortcode($post->post_content, 'audio')) {
         if (preg_match_all('/' . get_shortcode_regex() . '/s', $post->post_content, $matches, PREG_SET_ORDER)) {
             foreach ($matches as $shortcode) {
                 if ('audio' === $shortcode[2]) {
                     $html = do_shortcode($shortcode);
                     break;
                 }
             }
         }
     }
     // Check for autoembeds (links on their own lines) in the post content.
     if (empty($html) && preg_match_all('|^\\s*(https?://[^\\s"]+)\\s*$|im', $post->post_content, $matches)) {
         foreach ($matches[1] as $url) {
             $result = $wp_embed->shortcode(array(), $url);
             if (0 === strpos($result, '[audio')) {
                 $html = do_shortcode($result);
                 break;
             }
         }
     }
     // Check for audio attachments.
     if (empty($html)) {
         $attachments = get_posts(array('post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'audio', 'posts_per_page' => 1, 'fields' => 'ids', 'orderby' => 'menu_order', 'order' => 'asc'));
         if (!empty($attachments)) {
             $src = wp_get_attachment_url($attachments[0]);
             $html = wp_audio_shortcode(array('src' => $src));
         }
     }
     // Extract <audio> tags from the post content.
     if (empty($html)) {
         $embedded = get_media_embedded_in_content($post->post_content, array('audio'));
         $html = empty($embedded[0]) ? '' : $embedded[0];
     }
     // Reset the WP_Embed::return_false_on_fail setting.
     $wp_embed->return_false_on_fail = $return_false_on_fail;
     return apply_filters($this->theme->prefix . '_post_audio', $html, $post);
 }
    /**
     * df_video_embed
     * render shortcode output to frontend for video content
     */
    function df_video_post($atts, $content = null)
    {
        $atts = vc_map_get_attributes('df_video_post', $atts);
        extract($atts);
        $post_format = 'post-format-video';
        $args = $this->df_vc_atts_to_args($atts, $sort_order);
        // tax_query params for get only video post format
        $args = wp_parse_args(array('tax_query' => array(array('taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array($post_format)))), $args);
        // $posts = query_posts( $args );
        $posts = new WP_Query($args);
        $vid = '';
        ob_start();
        $title_text_color = isset($title_text_color) ? $title_text_color : '';
        $title == 'Block Title' ? $title = '' : $title;
        ?>

		<div class="df-vc-title-block" style="color:<?php 
        echo $title_text_color;
        ?>
 ;">
			<?php 
        echo $title;
        ?>
		</div>

		<?php 
        if ($posts->have_posts()) {
            ?>
		<div class="row posts">

		<?php 
            while ($posts->have_posts()) {
                $posts->the_post();
                $content = apply_filters('the_content', get_the_content());
                // print_r($content);
                $embeds = get_media_embedded_in_content($content);
                // contain iframe output video
                // print_r($embeds);
                // extract first url
                // $reg = preg_match('|^\s*(https?://[^\s"]+)\s*$|im', get_the_content(), $matches);
                // $vid_url = $matches[0];
                // end here
                ?>
				<div class="col-md-3">
				 	<?php 
                //echo $vid_url;
                ?>

				 	<?php 
                // echo $embeds[0];
                ?>
					
					<div class="embed-responsive embed-responsive-4by3">
				 	<?php 
                echo $embeds[0];
                ?>
				 	</div>
					<?php 
                if (has_post_thumbnail()) {
                    ?>
						<figure class="df-post-thumbnail">
							<a href="<?php 
                    the_permalink();
                    ?>
" title="<?php 
                    the_title();
                    ?>
" rel="bookmark">
								<?php 
                    the_post_thumbnail('post-thumbnail', array('itemprop' => 'image', 'class' => 'img-responsive'));
                    ?>
							</a>
						</figure>
					<?php 
                }
                ?>
	
						<header class="post-title entry-header">
							<?php 
                the_title('<h5 class="entry-title" itemprop="name headline"><a href="' . get_permalink() . '" title="' . the_title_attribute("echo=0") . '">', '</a></h5>');
                ?>
						</header>
						<!-- <div class="post-content entry-content small">
							<?php 
                //echo the_content();
                ?>
						</div> -->
				</div>
				
				
			<?php 
            }
            ?>
		</div>	
		<?php 
        }
        $out = ob_get_contents();
        if (ob_get_contents()) {
            ob_get_clean();
        }
        return $out;
        // $url = '';
        // if( $source == 'youtube' ){
        // 	if( !empty($youtube_url) ) {
        // 		$url = $youtube_url;
        // 	}
        // }else{
        // 	if( !empty($vimeo_url) ){
        // 		$url = $vimeo_url;
        // 	}
        // }
        // $output_embed = wp_oembed_get($url);
    }
Example #10
0
/**
 * Filters 'img' elements in post content to add 'srcset' and 'sizes' attributes.
 *
 * @since 4.4.0
 *
 * @see 'wp_image_add_srcset_and_sizes()'
 *
 * @param string $content The raw post content to be filtered.
 * @return string Converted content with 'srcset' and 'sizes' attributes added to images.
 */
function wp_make_content_images_responsive($content)
{
    $images = get_media_embedded_in_content($content, 'img');
    $selected_images = $attachment_ids = array();
    foreach ($images as $image) {
        if (false === strpos($image, ' srcset="') && preg_match('/wp-image-([0-9]+)/i', $image, $class_id) && ($attachment_id = absint($class_id[1]))) {
            /*
             * If exactly the same image tag is used more than once, overwrite it.
             * All identical tags will be replaced later with 'str_replace()'.
             */
            $selected_images[$image] = $attachment_id;
            // Overwrite the ID when the same image is included more than once.
            $attachment_ids[$attachment_id] = true;
        }
    }
    if (count($attachment_ids) > 1) {
        /*
         * Warm object cache for use with 'get_post_meta()'.
         *
         * To avoid making a database call for each image, a single query
         * warms the object cache with the meta information for all images.
         */
        update_meta_cache('post', array_keys($attachment_ids));
    }
    foreach ($selected_images as $image => $attachment_id) {
        $image_meta = get_post_meta($attachment_id, '_wp_attachment_metadata', true);
        $content = str_replace($image, wp_image_add_srcset_and_sizes($image, $image_meta, $attachment_id), $content);
    }
    return $content;
}
 /**
  * Retrieve a featured video.
  *
  * Returns first finded video, iframe, object or embed tag in content.
  *
  * @since 1.0.0
  * @param array $args Set of arguments.
  */
 public function get_post_format_video($args)
 {
     $args = wp_parse_args($args, $this->args['video_args']);
     /**
      * Filter post format video output to rewrite video from child theme or plugins.
      *
      * @since 1.0.0
      * @param bool|mixed $result Value to return instead of the featured video.
      *                           Default false to skip it.
      */
     $result = apply_filters('cherry_pre_get_post_video', false);
     if (false !== $result) {
         return $result;
     }
     $post_content = get_the_content();
     if (has_shortcode($post_content, 'video')) {
         $result_format = '%s';
     } else {
         $result_format = '<div class="entry-video embed-responsive embed-responsive-16by9">%s</div>';
     }
     /** This filter is documented in wp-includes/post-template.php */
     $content = apply_filters('the_content', $post_content);
     $types = array('video', 'object', 'embed', 'iframe');
     $embeds = get_media_embedded_in_content($content, $types);
     if (empty($embeds)) {
         return;
     }
     foreach ($types as $tag) {
         if (preg_match("/<{$tag}[^>]*>(.*?)<\\/{$tag}>/", $embeds[0], $matches)) {
             $result = $matches[0];
             break;
         }
     }
     if (false === $result) {
         return false;
     }
     $regex = array('/width=[\'\\"](\\d+)[\'\\"]/', '/height=[\'\\"](\\d+)[\'\\"]/');
     $replace = array('width="' . $args['width'] . '"', 'height="' . $args['height'] . '"');
     $result = preg_replace($regex, $replace, $result);
     $result = sprintf($result_format, $result);
     /**
      * Filter a featured video.
      *
      * @since 1.0.0
      * @param string $result Featured video.
      */
     return apply_filters('cherry_get_the_post_video', $result);
 }
Example #12
0
File: media.php Project: nkeat12/dv
    function test_get_media_embedded_in_content_order()
    {
        $audio = <<<AUDIO
<audio preload="none">
\t<source />
</audio>
AUDIO;
        $video = <<<VIDEO
<video preload="none">
\t<source />
</video>
VIDEO;
        $content = $audio . $video;
        $matches1 = get_media_embedded_in_content($content, array('audio', 'video'));
        $this->assertEquals(array($audio, $video), $matches1);
        $reversed = $video . $audio;
        $matches2 = get_media_embedded_in_content($reversed, array('audio', 'video'));
        $this->assertEquals(array($video, $audio), $matches2);
    }
 /**
  * Grabs media embbeded into the content within <iframe>, <object>, <embed>, and other HTML methods for 
  * embedding media.
  *
  * @since  1.6.0
  * @access public
  * @return void
  */
 public function do_embedded_media()
 {
     $embedded_media = get_media_embedded_in_content($this->content);
     if (!empty($embedded_media)) {
         $this->media = $this->original_media = array_shift($embedded_media);
     }
 }
Example #14
0
/**
 * Post Format: Audio
 * 
 * Get audio from an Audio
 * Find the audio and make sure it shows up on the index page
 * 
 * @link https://www.youtube.com/watch?v=HXLviEusCyE WP Theme Dev - Audio Post Format
 */
function jkl_get_the_audio()
{
    $output = '';
    if ('audio' === get_post_format()) {
        $content = apply_filters('the_content', get_the_content());
        $shortcode_content = do_shortcode($content);
        $embed = get_media_embedded_in_content($shortcode_content, array('audio', 'iframe'));
        $output = $embed[0];
    }
    echo $output;
}
Example #15
0
 function get_post_content_media($post_id = false)
 {
     global $post;
     $post_id = $post_id ? $post_id : $post->ID;
     $p = get_post($post_id);
     $content = do_shortcode(apply_filters('the_content', $p->post_content));
     return get_media_embedded_in_content($content);
 }
Example #16
0
function sunset_get_embedded_media($type = array())
{
    $content = do_shortcode(apply_filters('the_content', get_the_content()));
    $embed = get_media_embedded_in_content($content, $type);
    $output = str_replace('?visual=true', '?visual=false', $embed[0]);
    return $output;
}
Example #17
0
    $post_image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'single');
    $post_image = $post_image[0];
}
?>

	<article id="post-<?php 
the_ID();
?>
" <?php 
post_class();
?>
>
		<div class="post-thumbnail">
			<?php 
$content = do_shortcode(apply_filters('the_content', $post->post_content));
$media = get_media_embedded_in_content($content);
if (isset($media[0])) {
    echo balanceTags($media[0]);
}
?>
		</div>
		<div class="post-content">
			<?php 
koala_get_category();
?>
			<h2><a href="<?php 
the_permalink();
?>
"><?php 
the_title();
?>
Example #18
0
 /**
  *   Build content for different page instance
  */
 public function create_pages_contents()
 {
     global $post;
     if (is_home() || is_singular('post') || is_tag() || is_category() || is_archive() || is_search()) {
         $thumb_id = get_post_thumbnail_id($post->ID);
         $thumb_size = is_singular('post') ? 'full' : 'blog-thumb';
         $thumb_array = wp_get_attachment_image_src($thumb_id, $thumb_size, true);
         $alt_meta = get_post_meta($thumb_id, '_wp_attachment_image_alt', true);
         $post_format = get_post_format();
         $format_pat = '<figcaption><span class="bg-alpha"><i class="icon-%s"></i></span></figcaption>';
         switch ($post_format) {
             case 'aside':
                 $post_format_icon = sprintf($format_pat, '347');
                 break;
             case 'image':
                 $post_format_icon = sprintf($format_pat, '265');
                 break;
             case 'video':
                 $post_format_icon = sprintf($format_pat, '208');
                 break;
             case 'quote':
                 $post_format_icon = sprintf($format_pat, '375');
                 break;
             case 'link':
                 $post_format_icon = sprintf($format_pat, '296');
                 break;
             case 'gallery':
                 $post_format_icon = sprintf($format_pat, '222');
                 break;
             case 'audio':
                 $post_format_icon = sprintf($format_pat, '332');
                 break;
             default:
                 $post_format_icon = '';
                 break;
         }
         if (is_singular('post')) {
             $post_format_icon = '';
         }
         $content = do_shortcode(apply_filters('the_content', get_the_content($post->ID)));
         $embeds = get_media_embedded_in_content($content);
         $defaults = array('post_thumbnail' => $this->lazy_img($thumb_array[0], $alt_meta, $thumb_array[1], $thumb_array[2]), 'post_share' => '', 'post_format' => $post_format, 'post_format_icon' => $post_format_icon, 'video_embed' => !empty($embeds[0]) ? $embeds[0] : '');
         $format = get_post_format();
         $posts_format = !empty($format) ? '-' . $format : '';
         $this->tt_view('blog-loop', $defaults);
     } else {
         echo '<section class="box"><div class="container">';
         the_content();
         echo '</div></section>';
     }
 }
/**
 * Get featured audio.
 * Returns first finded audio tag in page content.
 *
 * @since 4.0.0
 */
function cherry_get_the_post_audio()
{
    /**
     * Filter post format audio output to rewrite audio from child theme or plugins.
     *
     * @since  4.0.0
     */
    $result = apply_filters('cherry_pre_get_post_audio', false);
    if (false !== $result) {
        return $result;
    }
    $content = get_the_content();
    $embeds = get_media_embedded_in_content(apply_filters('the_content', $content), array('audio'));
    if (empty($embeds)) {
        return;
    }
    if (false == preg_match('/<audio[^>]*>(.*?)<\\/audio>/', $embeds[0], $matches)) {
        return;
    }
    /**
     * Filter featured audio.
     *
     * @since 4.0.0
     */
    return apply_filters('cherry_get_the_post_audio', $matches[0]);
}
Example #20
0
				<?php 
    echo get_mtc_rating_sys('span', ' / ', '');
    ?>
			</p>					
		</div>
		<div class="spacer"></div>
	</div>
<?php 
} else {
    global $post;
    $the_content = get_the_content('', true);
    $the_content = apply_filters('the_content', $the_content);
    $the_content = str_replace(']]>', ']]&gt;', $the_content);
    $embed_code = rwmb_meta('mtc_embed_code', 'type=text');
    if (function_exists('get_media_embedded_in_content')) {
        $media = get_media_embedded_in_content($the_content, 'iframe');
        if (!empty($media)) {
            $pc = explode('</iframe>', $media[0]);
            $embed_code = $pc[0] . '</iframe>';
            $the_content = str_replace($embed_code, '', $the_content);
        }
    }
    if (!empty($embed_code)) {
        echo $embed_code;
    }
    ?>
	<div <?php 
    post_class();
    ?>
>	
		<div class="storycontent">
/**
 * Show entry format images, video, gallery, audio, etc.
 *
 * @return void
 */
function totomo_post_formats()
{
    $html = '';
    $size = 'totomo-thumb-blog-list';
    $thumb = get_the_post_thumbnail(get_the_ID(), $size);
    $post_link = get_permalink();
    switch (get_post_format()) {
        case 'link':
            $link = get_the_content();
            if ($link) {
                $html = "<div class='link-wrapper'>{$link}</div>";
            }
            break;
        case 'quote':
            $html = get_the_content();
            if (empty($thumb)) {
                break;
            }
            $html .= '<a class="post-image" href="' . get_permalink() . '">';
            $html .= $thumb;
            $html .= '</a>';
            break;
        case 'gallery':
            // Show gallery
            totomo_gallery_slider('thumb-blog-list');
            break;
        case 'audio':
            $content = apply_filters('the_content', get_the_content(__('Read More', 'totomo')));
            $media = get_media_embedded_in_content($content, array('audio', 'object', 'embed', 'iframe'));
            $thumb_audio = '';
            if (!empty($thumb)) {
                $html .= '<a class="post-image" href="' . get_permalink() . '">';
                $html .= $thumb;
                $html .= '</a>';
                $thumb_audio = 'thumb_audio';
            }
            if (!empty($media)) {
                ?>
				<?php 
                foreach ($media as $embed_html) {
                    $html .= sprintf('<div class="audio-wrapper %s">%s</div>', $thumb_audio, $embed_html);
                }
                ?>
			<?php 
            }
            break;
        case 'video':
            $content = apply_filters('the_content', get_the_content(__('Read More', 'totomo')));
            $media = get_media_embedded_in_content($content, array('video', 'object', 'embed', 'iframe'));
            if (!empty($media)) {
                ?>
				<?php 
                foreach ($media as $embed_html) {
                    $html = sprintf('%s', $embed_html);
                }
                ?>
			<?php 
            }
            break;
        default:
            if (empty($thumb)) {
                return;
            }
            $html .= '<a class="post-image" href="' . get_permalink() . '">';
            $html .= $thumb;
            $html .= '</a>';
    }
    if ($html) {
        echo "<div class='post-format-meta'>{$html}</div>";
    }
    $post_format = get_post_format(get_the_ID());
    if ('link' == $post_format || 'quote' == $post_format) {
        return;
    }
}
/**
 * Show first found video, iframe, object or embed tag in content.
 */
function azeria_post_video()
{
    $content = apply_filters('the_content', get_the_content());
    $types = array('video', 'object', 'embed', 'iframe');
    $embeds = get_media_embedded_in_content($content, $types);
    if (empty($embeds)) {
        return;
    }
    foreach ($types as $tag) {
        if (preg_match("/<{$tag}[^>]*>(.*?)<\\/{$tag}>/", $embeds[0], $matches)) {
            $result = $matches[0];
            break;
        }
    }
    if (false === $result) {
        return;
    }
    printf('<div class="entry-video embed-responsive embed-responsive-16by9">%s</div>', $result);
}
Example #23
0
the_ID();
?>
" <?php 
post_class();
?>
>
	<header class="entry-header">
		<div class="entry-meta">
			<?php 
gazette_entry_meta();
?>
		</div><!-- .entry-meta -->

		<?php 
$content = apply_filters('the_content', get_the_content());
$media = get_media_embedded_in_content($content, array('video', 'object', 'embed', 'iframe'));
if (!empty($media)) {
    printf('<div class="post-media jetpack-video-wrapper">%s</div>', $media[0]);
}
?>

		<?php 
the_title(sprintf('<h1 class="entry-title"><a href="%s" rel="bookmark">', esc_url(get_permalink())), '</a></h1>');
?>

		<div class="entry-meta">
			<?php 
gazette_posted_on();
?>
		</div><!-- .entry-meta -->
	</header><!-- .entry-header -->
Example #24
0
function mtc_scrolling_box_v3_grid($args)
{
    ?>
<div class="post_row">
	<div class="post-pager" id="news-latest"></div>
	<h2 class="ribbon-v3"><span><?php 
    echo $args['title'];
    ?>
</span></h2>
	<div class="box-latest-2">
	<section id="latest-2">
	<?php 
    $post_args = array('posts_per_page' => $args['per_page'], 'post_format' => 'post-format-video', 'orderby' => 'post_date', 'ignore_sticky_posts' => 1, 'order' => 'DESC');
    wp_reset_query();
    query_posts($post_args);
    while (have_posts()) {
        the_post();
        ?>
 	
		<article class="list-v2">
			<?php 
        if ('video' == get_post_format()) {
            $the_content = get_the_content('', true);
            $the_content = apply_filters('the_content', $the_content);
            $the_content = str_replace(']]>', ']]&gt;', $the_content);
            $embed_code = rwmb_meta('mtc_embed_code', 'type=text');
            if (function_exists('get_media_embedded_in_content')) {
                $media = get_media_embedded_in_content($the_content, 'iframe');
                if (!empty($media)) {
                    $pc = explode('</iframe>', $media[0]);
                    $embed_code = $pc[0] . '</iframe>';
                }
            }
            if (!empty($embed_code)) {
                echo $embed_code;
            } else {
                the_title();
            }
        } else {
            ?>
				<div class="thumb-v2">
				<?php 
            if (has_post_thumbnail()) {
                ?>
					<?php 
                the_post_thumbnail('blog-thumb');
                ?>
				<?php 
            } else {
                ?>
					<img src="<?php 
                echo get_template_directory_uri() . '/img/default_thumbnail_large.jpg';
                ?>
" alt="<?php 
                the_title();
                ?>
">
				<?php 
            }
            ?>
				</div>
				<div class="overlay"></div>
				
				<div class="content-v2">
					<h2><a href="<?php 
            the_permalink();
            ?>
"><?php 
            the_title();
            ?>
</a></h2>
					<span class="line">&nbsp;</span>
					<div class="panel-v">
						<ul>
							<li><a href="<?php 
            echo get_day_link(get_the_time('Y'), get_the_time('m'), get_the_time('d'));
            ?>
"><?php 
            the_time(get_option('date_format'));
            ?>
</a></li>
							<li><?php 
            the_author_posts_link();
            ?>
</li>
							<?php 
            echo get_mtc_rating_sys('span', '<li>', '</li>');
            ?>
						</ul>	
					</div>
				</div>
			<?php 
        }
        ?>
		</article>
		<?php 
    }
    /* Reset Query */
    wp_reset_query();
    ?>
	</section>
		<div class="clearfix"></div>
		<a class="prev" id="latest-2_prev" href="#"><i class="icon-angle-left"></i></a>
		<a class="next" id="latest-2_next" href="#"><i class="icon-angle-right"></i></a>
	</div>
</div>
<?php 
}
	function test_get_media_embedded_in_content() {
		$object =<<<OBJ
<object src="this" data="that">
	<param name="value"/>
</object>
OBJ;
		$embed =<<<EMBED
<embed src="something.mp4"/>
EMBED;
		$iframe =<<<IFRAME
<iframe src="youtube.com" width="7000" />
IFRAME;
		$audio =<<<AUDIO
<audio preload="none">
	<source />
</audio>
AUDIO;
		$video =<<<VIDEO
<video preload="none">
	<source />
</video>
VIDEO;

		$content =<<<CONTENT
This is a comment
$object

This is a comment
$embed

This is a comment
$iframe

This is a comment
$audio

This is a comment
$video

This is a comment
CONTENT;

		$types = array( 'audio', 'video', 'object', 'embed', 'iframe' );
		$contents = array_values( compact( $types ) );

		$matches = get_media_embedded_in_content( $content, 'audio' );
		$this->assertEquals( array( $audio ), $matches );

		$matches = get_media_embedded_in_content( $content, 'video' );
		$this->assertEquals( array( $video ), $matches );

		$matches = get_media_embedded_in_content( $content, 'object' );
		$this->assertEquals( array( $object ), $matches );

		$matches = get_media_embedded_in_content( $content, 'embed' );
		$this->assertEquals( array( $embed ), $matches );

		$matches = get_media_embedded_in_content( $content, 'iframe' );
		$this->assertEquals( array( $iframe ), $matches );

		$matches = get_media_embedded_in_content( $content, $types );
		$this->assertEquals( $contents, $matches );
	}
Example #26
0
function natural_lite_first_embed_media()
{
    global $post, $posts;
    $first_vid = '';
    $content = do_shortcode(apply_filters('the_content', $post->post_content));
    $embeds = get_media_embedded_in_content($content);
    if (!empty($embeds)) {
        foreach ($embeds as $embed) {
            if (strpos($embed, 'video') || strpos($embed, 'youtube') || strpos($embed, 'vimeo')) {
                return $embed;
            }
        }
    } else {
        return false;
    }
}
Example #27
0
/**
 * Filters 'img' elements in post content to add 'srcset' and 'sizes' attributes.
 *
 * @since 4.4.0
 *
 * @see wp_img_add_srcset_and_sizes()
 *
 * @param string $content The raw post content to be filtered.
 * @return string Converted content with 'srcset' and 'sizes' attributes added to images.
 */
function wp_make_content_images_responsive($content)
{
    $images = get_media_embedded_in_content($content, 'img');
    $attachment_ids = array();
    foreach ($images as $image) {
        if (preg_match('/wp-image-([0-9]+)/i', $image, $class_id)) {
            $attachment_id = (int) $class_id[1];
            if ($attachment_id) {
                $attachment_ids[] = $attachment_id;
            }
        }
    }
    if (0 < count($attachment_ids)) {
        /*
         * Warm object caches for use with wp_get_attachment_metadata.
         *
         * To avoid making a database call for each image, a single query
         * warms the object cache with the meta information for all images.
         */
        _prime_post_caches($attachment_ids, false, true);
    }
    foreach ($images as $image) {
        $content = str_replace($image, wp_img_add_srcset_and_sizes($image), $content);
    }
    return $content;
}
Example #28
0
function tally_get_first_embed_media($post_id, $type = 'video', $image = NULL)
{
    $post = get_post($post_id);
    $content = do_shortcode(apply_filters('the_content', $post->post_content));
    $embeds = get_media_embedded_in_content($content);
    if (!empty($embeds)) {
        if ($type == 'video') {
            foreach ($embeds as $embed) {
                if (strpos($embed, 'video') || strpos($embed, 'youtube') || strpos($embed, 'vimeo') || strpos($embed, 'iframe')) {
                    return '<div class="tally-embed-container">' . $embed . '</div>';
                }
            }
        } elseif ($type == 'audio') {
            foreach ($embeds as $embed) {
                if (strpos($embed, 'audio') && strpos($embed, 'wp-audio-shortcode')) {
                    if ($image != NULL) {
                        $image = '<img src="' . $image . '" alt="' . $post->title . '">';
                    }
                    return '<div class="">' . $image . $embed . '</div>';
                } else {
                    return '<div class="tally-embed-container">' . $embed . '</div>';
                }
            }
        }
    } else {
        //No video embedded found
        return false;
    }
}