Я использую эту функцию, чтобы получить HTML-код первого встраиваемого загруженного видео с сообщения с его идентификатором:
// Get first embed video from the post function 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 containing video tag, youtube or vimeo foreach ( $embeds as $embed ) { if ( strpos( $embed, 'video' ) || strpos( $embed, 'youtube' ) || strpos( $embed, 'vimeo' ) ) { return $embed; } } } else { // No video embedded found return false; } }
Это даст первый HTML-код для встраивания видео:
$html = get_first_embed_video( $post_id );
Я попытался проверить HTML возвращенного вложенного загруженного видео, но я не видел его идентификатор сообщения. Как я могу получить идентификатор сообщения возвращенного $embed
если это загруженное видео (.mp4) ?