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

Yoast / wordpress-seo / 2933c98962a853be2048beeb812f0fac9b2a8197

15 Jan 2026 04:12PM UTC coverage: 53.19% (+0.4%) from 52.832%
2933c98962a853be2048beeb812f0fac9b2a8197

Pull #22887

github

web-flow
Merge edcd36026 into d394743dd
Pull Request #22887: Add a new key for step attribute and adapt the relevant code and make…

8774 of 16370 branches covered (53.6%)

Branch coverage included in aggregate %.

5 of 135 new or added lines in 14 files covered. (3.7%)

42 existing lines in 4 files now uncovered.

32905 of 61988 relevant lines covered (53.08%)

46516.26 hits per line

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

0.0
/packages/js/src/structured-data-blocks/shared-utils/getImageSrc.js
NEW
1
const parser = new DOMParser();
×
2

3
/**
4
 * Get the src of the first image src from the contents.
5
 * @param {Array|string} contents The contents to search for an image.
6
 * @returns {boolean|string} The image src or false if none is found.
7
 */
NEW
8
export const getImageSrc = ( contents ) => {
×
9
        // Handle legacy array format for backward compatibility.
NEW
10
        if ( Array.isArray( contents ) ) {
×
11
                // Find the first image node.
NEW
12
                const image = contents.find( ( node ) => node && node.type === "img" );
×
NEW
13
                return image ? image.props.src : false;
×
14
        }
15

16
        // Handle new string format - parse for img tag.
NEW
17
        if ( typeof contents === "string" && contents.includes( "<img" ) ) {
×
18
                // Use a DOM parser to extract the src attribute.
NEW
19
                const doc = parser.parseFromString( contents, "text/html" );
×
20
                // Only return the first image found.
NEW
21
                const img = doc.querySelector( "img" );
×
NEW
22
                if ( img && img.src ) {
×
NEW
23
                        return img.src;
×
24
                }
25
        }
26

NEW
27
        return false;
×
28
};
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

© 2026 Coveralls, Inc