LLMS_Post_Model::to_array_extra_images( string $content )
Add images found in the post’s content to the post’s array
Parameters Parameters
- $content
-
(string) (Required) Raw
post_contentstring.
Return Return
(string[]) Array of image source URLs.
Source Source
File: includes/abstracts/abstract.llms.post.model.php
protected function to_array_extra_images( $content ) {
$images = array();
$dom = llms_get_dom_document( $content );
if ( is_wp_error( $dom ) ) {
return $images;
}
$site_url = get_site_url();
foreach ( $dom->getElementsByTagName( 'img' ) as $img ) {
$src = $img->getAttribute( 'src' );
// Only include images stored in this site's media library.
if ( 0 !== strpos( $src, $site_url ) ) {
continue;
}
$images[] = $src;
}
return array_values( array_unique( $images ) );
}
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 4.7.0 | Introduced. |