bp_core_extract_media_from_content( string $content = '', string|int $type = 'all' )
Extracts media metadata from a given content.
Description
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'
Return
(false|array) If media exists, will return array of media metadata. Else, boolean false.
Source
File: bp-core/bp-core-functions.php
1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 | 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; } |
Changelog
Version | Description |
---|---|
BuddyPress 2.6.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.