Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional Filters For Images & Extended Delays #8313

Merged
merged 4 commits into from
Jan 30, 2018

Conversation

Volnus
Copy link
Contributor

@Volnus Volnus commented Dec 6, 2017

This PR proposes a couple of new filters for getting images most notably those within text-widgets. In addition, it also extends the delay to the PHP_MAX and the reason for this is because many plugins and themes i found are (and I am guilty of this too in the past) of putting their delays as 9999999 which albeit is a bad practice but because of this, many themes (notably from a particular online marketplace) aren't getting their images lazy loaded.

This change allows more images to be affected by the filter and pushes the delay to the max that it can be without us just slapping a bunch of 9's on the delay.

Fixes #

Changes proposed in this Pull Request:

Testing instructions:

Proposed changelog entry for your changes:

This PR proposes a couple of new filters for getting images most notably those within text-widgets. In addition, it also extends the delay to the PHP_MAX and the reason for this is because many plugins and themes i found are (and I am guilty of this too in the past) of putting their delays as 9999999 which albeit is a bad practice but because of this, many themes (notably from a particular online marketplace) aren't getting their images lazy loaded. 

This change allows more images to be affected by the filter and pushes the delay to the max that it can be without us just slapping a bunch of 9's on the delay.
@Volnus Volnus requested a review from a team as a code owner December 6, 2017 01:45
@jeherve jeherve added [Feature] Lazy Images [Pri] Normal [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it labels Dec 6, 2017
@jeherve jeherve requested a review from ebinnion December 6, 2017 10:49
Copy link
Contributor

@ebinnion ebinnion left a comment

Choose a reason for hiding this comment

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

This tests well. I left a few comments about coding standards. Besides that, LGTM though.

add_filter( 'the_content', array( $this, 'add_image_placeholders' ), PHP_INT_MAX ); // run this later, so other content filters have run, including image_add_wh on WP.com
add_filter( 'post_thumbnail_html', array( $this, 'add_image_placeholders' ), PHP_INT_MAX );
add_filter( 'get_avatar', array( $this, 'add_image_placeholders' ), PHP_INT_MAX );
add_filter( 'widget_text', array($this, 'add_image_placeholders' ), PHP_INT_MAX );
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick, but could you please add a space between array( and $this.

add_filter( 'post_thumbnail_html', array( $this, 'add_image_placeholders' ), PHP_INT_MAX );
add_filter( 'get_avatar', array( $this, 'add_image_placeholders' ), PHP_INT_MAX );
add_filter( 'widget_text', array($this, 'add_image_placeholders' ), PHP_INT_MAX );
add_filter( 'get_image_tag', array($this, 'add_image_placeholders' ), PHP_INT_MAX);
Copy link
Contributor

Choose a reason for hiding this comment

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

Also, would you add the space here between array( and $this please.

remove_filter( 'the_content', array( $this, 'add_image_placeholders' ), PHP_INT_MAX );
remove_filter( 'post_thumbnail_html', array( $this, 'add_image_placeholders' ), PHP_INT_MAX );
remove_filter( 'get_avatar', array( $this, 'add_image_placeholders' ), PHP_INT_MAX );
remove_filter( 'widget_text', array($this, 'add_image_placeholders' ), PHP_INT_MAX );
Copy link
Contributor

Choose a reason for hiding this comment

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

Same with this line and the one below it.

fixed spacing issues.
@Volnus
Copy link
Contributor Author

Volnus commented Dec 7, 2017

I fixed the spacing issues highlighted by @ebinnion

@jeherve jeherve added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. labels Dec 8, 2017
@oskosk
Copy link
Contributor

oskosk commented Dec 20, 2017

@Volnus can you rebase this branch. There are some conflicts now.

Thanks!

I'm relabeling as needs review.

@oskosk oskosk added [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. and removed [Status] Ready to Merge Go ahead, you can push that green button! labels Dec 20, 2017
@oskosk oskosk added this to the 5.8 milestone Dec 26, 2017
@jeherve jeherve added [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! and removed [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. labels Dec 29, 2017
Copy link
Member

@zinigor zinigor left a comment

Choose a reason for hiding this comment

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

Fixed conflicts, should be ready to merge now.

@zinigor zinigor added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! labels Jan 29, 2018
@zinigor zinigor merged commit 057aaac into Automattic:master Jan 30, 2018
@zinigor zinigor removed the [Status] Ready to Merge Go ahead, you can push that green button! label Jan 30, 2018
jeherve added a commit that referenced this pull request Jan 30, 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Lazy Images [Pri] Normal [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants