Yoast\WP\SEO\Presenters\Open_Graph
Image_Presenter::filter()
Run the image content through the wpseo_opengraph_image
Метод класса: Image_Presenter{}
Хуки из метода
Возвращает
Массив<Строку,int>
. The filtered image.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->filter( $image );
- $image(array<string,int>) (обязательный)
- The image.
Код Image_Presenter::filter() Image Presenter::filter Yoast 24.0
protected function filter( $image ) { /** * Filter: 'wpseo_opengraph_image' - Allow changing the Open Graph image url. * * @param string $image_url The URL of the Open Graph image. * @param Indexable_Presentation $presentation The presentation of an indexable. */ $image_url = \apply_filters( 'wpseo_opengraph_image', $image['url'], $this->presentation ); if ( ! empty( $image_url ) && \is_string( $image_url ) ) { $image['url'] = \trim( $image_url ); } $image_type = ( $image['type'] ?? '' ); /** * Filter: 'wpseo_opengraph_image_type' - Allow changing the Open Graph image type. * * @param string $image_type The type of the Open Graph image. * @param Indexable_Presentation $presentation The presentation of an indexable. */ $image_type = \apply_filters( 'wpseo_opengraph_image_type', $image_type, $this->presentation ); if ( ! empty( $image_type ) && \is_string( $image_type ) ) { $image['type'] = \trim( $image_type ); } else { $image['type'] = ''; } $image_width = ( $image['width'] ?? '' ); /** * Filter: 'wpseo_opengraph_image_width' - Allow changing the Open Graph image width. * * @param int $image_width The width of the Open Graph image. * @param Indexable_Presentation $presentation The presentation of an indexable. */ $image_width = (int) \apply_filters( 'wpseo_opengraph_image_width', $image_width, $this->presentation ); if ( ! empty( $image_width ) && $image_width > 0 ) { $image['width'] = $image_width; } else { $image['width'] = ''; } $image_height = ( $image['height'] ?? '' ); /** * Filter: 'wpseo_opengraph_image_height' - Allow changing the Open Graph image height. * * @param int $image_height The height of the Open Graph image. * @param Indexable_Presentation $presentation The presentation of an indexable. */ $image_height = (int) \apply_filters( 'wpseo_opengraph_image_height', $image_height, $this->presentation ); if ( ! empty( $image_height ) && $image_height > 0 ) { $image['height'] = $image_height; } else { $image['height'] = ''; } return $image; }