WPSEO_Image_Utils::get_first_content_image_for_term()public staticYoast 1.0

Gets the term's first usable content image. Null if none is available.

Метод класса: WPSEO_Image_Utils{}

Хуков нет.

Возвращает

Строку|null. The image URL.

Использование

$result = WPSEO_Image_Utils::get_first_content_image_for_term( $term_id );
$term_id(int) (обязательный)
The term id.

Код WPSEO_Image_Utils::get_first_content_image_for_term() Yoast 24.9

public static function get_first_content_image_for_term( $term_id ) {
	$term_description = term_description( $term_id );

	// We know term_description() returns a string which may be empty.
	if ( $term_description === '' ) {
		return null;
	}

	$image_finder = new WPSEO_Content_Images();
	$images       = $image_finder->get_images_from_content( $term_description );

	return self::get_first_image( $images );
}