get_media_embedded_in_content
函数
get_media_embedded_in_content ( $content, $types = null )
- 参数
-
-
(string)
$content
A string of HTML which might contain media elements.- Required: 是
-
(string[])
$types
An array of media types: ‘audio’, ‘video’, ‘object’, ’embed’, or ‘iframe’.- Required: 否
- Default: null
-
(string)
- 返回值
-
- (string[]) Array of found HTML media elements.
- 定义位置
-
-
wp-includes/media.php
, line 4803
-
wp-includes/media.php
- 引入
- 3.6.0
- 弃用
- –
Checks the HTML content for a audio, video, object, embed, or iframe tags.
function get_media_embedded_in_content( $content, $types = null ) { $html = array(); /** * Filters the embedded media types that are allowed to be returned from the content blob. * * @since 4.2.0 * * @param string[] $allowed_media_types An array of allowed media types. Default media types are * 'audio', 'video', 'object', 'embed', and 'iframe'. */ $allowed_media_types = apply_filters( 'media_embedded_in_content_allowed_types', array( 'audio', 'video', 'object', 'embed', 'iframe' ) ); if ( ! empty( $types ) ) { if ( ! is_array( $types ) ) { $types = array( $types ); } $allowed_media_types = array_intersect( $allowed_media_types, $types ); } $tags = implode( '|', $allowed_media_types ); if ( preg_match_all( '#' . $tags . ')[^[sS]*?(?P=tag)>|s*/>)#', $content, $matches ) ) { foreach ( $matches[0] as $match ) { $html[] = $match; } } return $html; }
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。