Skip to content

Fix lazy images issue with Gazette theme#8499

Merged
gravityrail merged 3 commits intomasterfrom
fix/skip-lazy-images-for-gazette-featured-content
Jan 23, 2018
Merged

Fix lazy images issue with Gazette theme#8499
gravityrail merged 3 commits intomasterfrom
fix/skip-lazy-images-for-gazette-featured-content

Conversation

@gravityrail
Copy link
Copy Markdown
Contributor

@gravityrail gravityrail commented Jan 11, 2018

Fixes blank featured images in top area of Gazette theme when Lazy Images is switched on.

https://wordpress.org/support/topic/no-header-images-with-jetpack-lazy-images/#post-9849480

The issue is that Gazette rendered out the original image, then in javascript they copy the image src attribute and put it in the style attribute of the parent tag as background-image: url( 'the-original-image' ), then hide the original image tag - which in the case of lazy images means they are essentially copying the placeholder into the parent where we can't modify it.

This PR is my attempt at the simplest, narrowest solution targeting this theme. Open to better suggestions!

Testing instructions:

To see the issue:

  • Activate Gazette theme
  • Add some posts with featured images and "featured' tag
  • Go to your main blog index
  • You should see blocks above the header bar with the featured posts in them
  • Activate lazy images
  • Reload blog page - post featured images should now be missing (black square)

To test this patch:

  • Do the above - images should now be present.

Proposed changelog entry for your changes:

@gravityrail gravityrail requested a review from a team as a code owner January 11, 2018 04:21
@gravityrail gravityrail requested a review from ebinnion January 11, 2018 04:21
@gravityrail gravityrail self-assigned this Jan 11, 2018
@gravityrail gravityrail added this to the 5.8 milestone Jan 11, 2018
}

// check for gazette featured images, which are incompatible
if ( isset( $attributes['class'] ) && strpos( $attributes['class'], 'gazette-featured-content-thumbnail' ) > 0 ) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use false !== strpos() instead to avoid the situation where gazette-featured-content-thumbnail is the first thing in the string.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!! Fixed.

@jeherve jeherve added the Bug When a feature is broken and / or not performing as intended label Jan 11, 2018
@gravityrail gravityrail merged commit fc777e7 into master Jan 23, 2018
@gravityrail gravityrail deleted the fix/skip-lazy-images-for-gazette-featured-content branch January 23, 2018 00:14
jeherve added a commit that referenced this pull request Jan 25, 2018
zinigor pushed a commit that referenced this pull request Jan 30, 2018
* Changelog 5.8: create base for changelog.

* Update 5.8 release post link

* fix 5.8 release date

* Updates to plugin description

* Changelog: add #8499

* Changelog: add #8506

* Changelog: add #8509

* Changelog: add #8516

* Changelog: add #8517

* Changelog: add #8523

* Changelog: add #8547

* Changelog: add #8496

* Changelog: add #8584

* Changelog: add #8595

* Changelog: add #8445

* Changelog: add #8431

* Changelog: add #8284

* Changelog: add #8270

* Changelog: add #8124

* Changelog: add #8581

* Changelog: add #8463

* Changelog: add #8568 (#8646)

* Updates to testing list and changelog

* Changelog: add #8443

* Changelog: add #8459

* Changelog: add #8469

* Changelog: add #8464

* Changelog: add #8478 and #8479

* Changelog: add #8483

* Changelog: add #8488

* Changelog: add #8513

* Changelog: add #8555

* Changelog: add #8565

* Changelog: add #8601

* Changelog: add #8612

* Changelog: add first pass at Search items.

* Changelog: add more info to help test Search.

* Changelog: add #8144

* Changelog: add #8313

* Changelog: add #8419

* Changelog: add #8465

* Changelog: add #8515

* Changelog: add #8587

* Changelog: add #8591

* Changelog: add #8659

* Changelog: add #8661

* Changelog: add #8671

* Changelog: add 5.7.1 to archived changelog too.

* Reverted changes to readme, removed entry about backups.
@kraftbj kraftbj removed the [Status] Needs Review This PR is ready for review. label Sep 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug When a feature is broken and / or not performing as intended [Feature] Lazy Images

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants