bp_core_extract_media_from_content( string $content = '', string|int $type = 'all' )

Extracts media metadata from a given content.


Description Description


Parameters Parameters

$content

(Optional) The content to check.

Default value: ''

$type

(Optional) The type to check. Can also use a bitmask. See the class constants in the BP_Media_Extractor class for more info.

Default value: 'all'


Top ↑

Return Return

(false|array) If media exists, will return array of media metadata. Else, boolean false.


Top ↑

Source Source

File: bp-core/bp-core-functions.php

function bp_core_extract_media_from_content( $content = '', $type = 'all' ) {
	if ( is_string( $type ) ) {
		$class = new ReflectionClass( 'BP_Media_Extractor' );
		$bitmask = $class->getConstant( strtoupper( $type ) );
	} else {
		$bitmask = (int) $type;
	}

	// Type isn't valid, so bail.
	if ( empty( $bitmask ) ) {
		return false;
	}

	$x = new BP_Media_Extractor;
	$media = $x->extract( $content, $bitmask );

	unset( $media['has'] );
	$retval = array_filter( $media );

	return ! empty( $retval ) ? $retval : false;
}

Top ↑

Changelog Changelog

Changelog
Version Description
2.6.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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