当前位置: 首页>>代码示例>>PHP>>正文


PHP get_media_embedded_in_content函数代码示例

本文整理汇总了PHP中get_media_embedded_in_content函数的典型用法代码示例。如果您正苦于以下问题:PHP get_media_embedded_in_content函数的具体用法?PHP get_media_embedded_in_content怎么用?PHP get_media_embedded_in_content使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_media_embedded_in_content函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: realistic_get_first_embed_video

 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;
     }
 }
开发者ID:benediktharter,项目名称:Realistic,代码行数:17,代码来源:functions.php

示例2: bambule_get_embedded_media

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;
}
开发者ID:bambuleger,项目名称:bambule,代码行数:11,代码来源:general-functions.php

示例3: ods_get_first_embed_media

/**
 * @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;
    }
}
开发者ID:kding0409,项目名称:kding0409.github.io,代码行数:15,代码来源:ods_functions.php

示例4: get_first_embed_media

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;
    }
}
开发者ID:sleeping-lion,项目名称:dojisa,代码行数:12,代码来源:functions.php

示例5: post_grid_first_embed_media

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;
    }
}
开发者ID:NallelyFlores89,项目名称:cronica-ambiental,代码行数:13,代码来源:post-grid-functions.php

示例6: jetpack_responsive_videos_init

/**
 * 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');
}
开发者ID:sixhours,项目名称:jetpack,代码行数:19,代码来源:responsive-videos.php

示例7: the_title

    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>
开发者ID:CompositeUK,项目名称:clone.WordPress-Develop,代码行数:31,代码来源:content-audio.php

示例8: get_audio

 /**
  * 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);
 }
开发者ID:TyRichards,项目名称:ty_the_band,代码行数:56,代码来源:class-cedaro-theme-postmedia.php

示例9: df_video_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 
        }
//.........这里部分代码省略.........
开发者ID:willi-dev,项目名称:vc_extender,代码行数:101,代码来源:df-vc-extender-shortcode.php

示例10: wp_make_content_images_responsive

/**
 * 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;
}
开发者ID:rowena-altastratus,项目名称:wordpress,代码行数:40,代码来源:media.php

示例11: get_post_format_video

 /**
  * 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);
 }
开发者ID:CherryFramework,项目名称:cherry-framework,代码行数:56,代码来源:cherry-post-formats-api.php

示例12: test_get_media_embedded_in_content_order

    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);
    }
开发者ID:nkeat12,项目名称:dv,代码行数:19,代码来源:media.php

示例13: do_embedded_media

 /**
  * 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);
     }
 }
开发者ID:highergroundstudio,项目名称:hybrid-core,代码行数:15,代码来源:hybrid-media-grabber.php

示例14: jkl_get_the_audio

/**
 * 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;
}
开发者ID:jekkilekki,项目名称:theme-jkl,代码行数:19,代码来源:template-tags.php

示例15: get_post_content_media

 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);
 }
开发者ID:Rameshbhushal,项目名称:newsroom,代码行数:8,代码来源:featured-media.php


注:本文中的get_media_embedded_in_content函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。