| @@ -14,35 +14,27 @@ | ||
| 14 | 14 | * |
| 15 | 15 | * @return bool |
| 16 | 16 | */ |
| 17 | 17 | public function is_needed() { |
| 18 | - return $this->context->indexable->object_type === 'post'; | |
| 18 | + return true; | |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | 22 | * Adds a main image for the current URL to the schema if there is one. |
| 23 | 23 | * |
| 24 | - * This can be either a social image (Open Graph or Twitter), the featured image, | |
| 25 | - * or fall back to the first image in the content of the page. | |
| 24 | + * This can be either the featured image or the first image in the content of the page. | |
| 26 | 25 | * |
| 27 | - * @return false|array Image Schema. | |
| 26 | + * @return array|false Image Schema. | |
| 28 | 27 | */ |
| 29 | 28 | public function generate() { |
| 30 | 29 | $image_id = $this->context->canonical . Schema_IDs::PRIMARY_IMAGE_HASH; |
| 31 | 30 | |
| 32 | - // The Open Graph image. | |
| 33 | - if ( isset( $this->context->indexable->open_graph_image_id ) && $this->context->indexable->open_graph_image_source === 'set-by-user' ) { | |
| 34 | - return $this->helpers->schema->image->generate_from_attachment_id( $image_id, $this->context->indexable->open_graph_image_id ); | |
| 35 | - } | |
| 36 | - | |
| 37 | - // The Twitter image. | |
| 38 | - if ( isset( $this->context->indexable->twitter_image_id ) && $this->context->indexable->twitter_image_source === 'set-by-user' ) { | |
| 39 | - return $this->helpers->schema->image->generate_from_attachment_id( $image_id, $this->context->indexable->twitter_image_id ); | |
| 40 | - } | |
| 41 | - | |
| 42 | 31 | // The featured image. |
| 43 | 32 | if ( $this->context->main_image_id ) { |
| 44 | - return $this->helpers->schema->image->generate_from_attachment_id( $image_id, $this->context->main_image_id ); | |
| 33 | + $generated_schema = $this->helpers->schema->image->generate_from_attachment_id( $image_id, $this->context->main_image_id ); | |
| 34 | + $this->context->main_image_url = $generated_schema['url']; | |
| 35 | + | |
| 36 | + return $generated_schema; | |
| 45 | 37 | } |
| 46 | 38 | |
| 47 | 39 | // The first image in the content. |
| 48 | 40 | if ( $this->context->main_image_url ) { |