WPSEO_Image_Utils::get_first_image()protected staticYoast 1.0

Retrieves the first possible image url from an array of images.

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

Хуков нет.

Возвращает

Строку|null. The extracted image url when found, null when not found.

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

$result = WPSEO_Image_Utils::get_first_image( $images );
$images(массив) (обязательный)
The array to extract image url from.

Код WPSEO_Image_Utils::get_first_image() Yoast 22.3

protected static function get_first_image( $images ) {
	if ( ! is_array( $images ) ) {
		return null;
	}

	$images = array_filter( $images );
	if ( empty( $images ) ) {
		return null;
	}

	return reset( $images );
}