• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Yoast / wordpress-seo / 6987097851

25 Nov 2023 04:49AM UTC coverage: 49.206% (-0.1%) from 49.302%
6987097851

push

github

web-flow
Merge pull request #20878 from Yoast/JRF/ghactions-minor-tweak

GH Actions: update a few links in inline comments

15305 of 31104 relevant lines covered (49.21%)

4.03 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

81.82
/src/generators/schema/main-image.php
1
<?php
2

3
namespace Yoast\WP\SEO\Generators\Schema;
4

5
use Yoast\WP\SEO\Config\Schema_IDs;
6

7
/**
8
 * Returns ImageObject schema data.
9
 */
10
class Main_Image extends Abstract_Schema_Piece {
11

12
        /**
13
         * Determines whether or not a piece should be added to the graph.
14
         *
15
         * @return bool
16
         */
17
        public function is_needed() {
×
18
                return true;
×
19
        }
20

21
        /**
22
         * Adds a main image for the current URL to the schema if there is one.
23
         *
24
         * This can be either the featured image or the first image in the content of the page.
25
         *
26
         * @return false|array Image Schema.
27
         */
28
        public function generate() {
6✔
29
                $image_id = $this->context->canonical . Schema_IDs::PRIMARY_IMAGE_HASH;
6✔
30

31
                // The featured image.
32
                if ( $this->context->main_image_id ) {
6✔
33
                        $generated_schema              = $this->helpers->schema->image->generate_from_attachment_id( $image_id, $this->context->main_image_id );
2✔
34
                        $this->context->main_image_url = $generated_schema['url'];
2✔
35

36
                        return $generated_schema;
2✔
37
                }
38

39
                // The first image in the content.
40
                if ( $this->context->main_image_url ) {
4✔
41
                        return $this->helpers->schema->image->generate_from_url( $image_id, $this->context->main_image_url );
2✔
42
                }
43

44
                return false;
2✔
45
        }
46
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc