Yoast\WP\SEO\Helpers

Image_Helper::get_attachment_meta_from_settings()publicYoast 1.0

Based on and image ID return array with the best variation of that image. If it's not saved to the DB, save it to an option.

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

Хуков нет.

Возвращает

Массив|true|false. Array with image details when the image is found, boolean when it's not found.

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

$Image_Helper = new Image_Helper();
$Image_Helper->get_attachment_meta_from_settings( $setting );
$setting(строка) (обязательный)
The setting name. Should be company or person.

Код Image_Helper::get_attachment_meta_from_settings() Yoast 22.4

public function get_attachment_meta_from_settings( $setting ) {
	$image_meta = $this->options_helper->get( $setting . '_meta', false );
	if ( ! $image_meta ) {
		$image_id = $this->options_helper->get( $setting . '_id', false );
		if ( $image_id ) {
			// There is not an option to put a URL in an image field in the settings anymore, only to upload it through the media manager.
			// This means an attachment always exists, so doing this is only needed once.
			$image_meta = $this->get_best_attachment_variation( $image_id );
			if ( $image_meta ) {
				$this->options_helper->set( $setting . '_meta', $image_meta );
			}
		}
	}

	return $image_meta;
}