LLMS_Post_Model::to_array_extra_images( string $content )

Add images found in the post’s content to the post’s array


Description Description


Parameters Parameters

$content

(string) (Required) Raw post_content string.


Top ↑

Return Return

(string[]) Array of image source URLs.


Top ↑

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 ) );

	}

Top ↑

Changelog Changelog

Changelog
Version Description
4.7.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

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