• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP get_media_embedded_in_content函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: sunset_get_embedded_media

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;
}
开发者ID:Alecaddd,项目名称:Sunset-theme,代码行数:7,代码来源:theme-support.php


示例17: wp_get_attachment_image_src

    $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();
?>
开发者ID:wesayso,项目名称:gy-blog,代码行数:31,代码来源:video.php


示例18: create_pages_contents

 /**
  *   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>';
     }
 }
开发者ID:sissisnothere,项目名称:testWeb,代码行数:54,代码来源:functions.php


示例19: cherry_get_the_post_audio

/**
 * 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]);
}
开发者ID:roberto-alarcon,项目名称:Neuroglobal,代码行数:32,代码来源:template-post.php


示例20: totomo_post_formats

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP get_media_item函数代码示例发布时间:2022-05-15
下一篇:
PHP get_mb_substr函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap