astra_get_video_from_post( number $post_id )

Get first image from post content


Description


Parameters

$post_id

(number) (Required) Post id.


Return

(mixed)


Source

File: inc/blog/blog.php

	function astra_get_video_from_post( $post_id ) {

		$post    = get_post( $post_id );
		$content = do_shortcode( apply_filters( 'the_content', $post->post_content ) );
		$embeds  = apply_filters( 'astra_get_post_audio', get_media_embedded_in_content( $content ) );

		if ( empty( $embeds ) ) {
			return '';
		}

		// 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' ) ) {
				return $embed;
			}
		}
	}

Changelog

Changelog
Version Description
1.0 Introduced.


User Contributed Notes

You must log in before being able to contribute a note or feedback.