Skip to content

Commit fb0928f

Browse files
committed
Avoid identifying noscript fallback img as hero image candidates
1 parent 06de9df commit fb0928f

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/Transformer/DetermineHeroImages.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,21 @@ final class DetermineHeroImages implements Transformer {
3737
*
3838
* @var string
3939
*/
40-
const CUSTOM_HEADER_XPATH_QUERY = ".//*[ @id = 'wp-custom-header' or @id = 'masthead' or @id = 'site-header' or contains( concat( ' ', normalize-space( @class ), ' ' ), ' wp-custom-header ' ) ]//*[ ( self::img or self::amp-img ) and not( @data-hero ) and not( contains( concat( ' ', normalize-space( @class ), ' ' ), ' custom-logo ' ) ) ]";
40+
const CUSTOM_HEADER_XPATH_QUERY = ".//*[ @id = 'wp-custom-header' or @id = 'masthead' or @id = 'site-header' or contains( concat( ' ', normalize-space( @class ), ' ' ), ' wp-custom-header ' ) ]//*[ ( self::amp-img or ( self::img and not( parent::noscript ) ) ) and not( @data-hero ) and not( contains( concat( ' ', normalize-space( @class ), ' ' ), ' custom-logo ' ) ) ]";
4141

4242
/**
4343
* XPath query to find the custom logo.
4444
*
4545
* @var string
4646
*/
47-
const CUSTOM_LOGO_XPATH_QUERY = ".//a[ contains( concat( ' ', normalize-space( @class ), ' ' ), ' custom-logo-link ' ) ]//*[ ( self::img or self::amp-img ) and contains( concat( ' ', normalize-space( @class ), ' ' ), ' custom-logo ' ) ][ not( @data-hero ) ]";
47+
const CUSTOM_LOGO_XPATH_QUERY = ".//a[ contains( concat( ' ', normalize-space( @class ), ' ' ), ' custom-logo-link ' ) ]//*[ ( self::amp-img or ( self::img and not( parent::noscript ) ) ) and contains( concat( ' ', normalize-space( @class ), ' ' ), ' custom-logo ' ) ][ not( @data-hero ) ]";
4848

4949
/**
5050
* XPath query to find the featured image.
5151
*
5252
* @var string
5353
*/
54-
const FEATURED_IMAGE_XPATH_QUERY = ".//*[ ( self::img or self::amp-img ) and contains( concat( ' ', normalize-space( @class ), ' ' ), ' wp-post-image ' ) ][ not( @data-hero ) ]";
54+
const FEATURED_IMAGE_XPATH_QUERY = ".//*[ ( self::amp-img or ( self::img and not( parent::noscript ) ) ) and contains( concat( ' ', normalize-space( @class ), ' ' ), ' wp-post-image ' ) ][ not( @data-hero ) ]";
5555

5656
/**
5757
* XPath query to find the first entry-content.
@@ -65,14 +65,14 @@ final class DetermineHeroImages implements Transformer {
6565
*
6666
* @var string
6767
*/
68-
const INITIAL_COVER_BLOCK_XPATH_QUERY = "./*[1]/descendant-or-self::div[ contains( concat( ' ', normalize-space( @class ), ' ' ), ' wp-block-cover ' ) ]/*[ ( self::img or self::amp-img ) and contains( concat( ' ', normalize-space( @class ), ' ' ), ' wp-block-cover__image-background ' ) ][ not( @data-hero ) ]";
68+
const INITIAL_COVER_BLOCK_XPATH_QUERY = "./*[1]/descendant-or-self::div[ contains( concat( ' ', normalize-space( @class ), ' ' ), ' wp-block-cover ' ) ]/*[ ( self::amp-img or ( self::img and not( parent::noscript ) ) ) and contains( concat( ' ', normalize-space( @class ), ' ' ), ' wp-block-cover__image-background ' ) ][ not( @data-hero ) ]";
6969

7070
/**
7171
* XPath query to find Image Block at the beginning of post content (including nested inside of another block).
7272
*
7373
* @var string
7474
*/
75-
const INITIAL_IMAGE_BLOCK_XPATH_QUERY = "./*[1]/descendant-or-self::figure[ contains( concat( ' ', normalize-space( @class ), ' ' ), ' wp-block-image ' ) ]/*[ ( self::img or self::amp-img ) ][ not( @data-hero ) ]";
75+
const INITIAL_IMAGE_BLOCK_XPATH_QUERY = "./*[1]/descendant-or-self::figure[ contains( concat( ' ', normalize-space( @class ), ' ' ), ' wp-block-image ' ) ]/*[ ( self::amp-img or ( self::img and not( parent::noscript ) ) ) ][ not( @data-hero ) ]";
7676

7777
/**
7878
* Apply transformations to the provided DOM document.

0 commit comments

Comments
 (0)