Additional Filters For Images & Extended Delays#8313
Merged
zinigor merged 4 commits intoAutomattic:masterfrom Jan 30, 2018
Merged
Additional Filters For Images & Extended Delays#8313zinigor merged 4 commits intoAutomattic:masterfrom
zinigor merged 4 commits intoAutomattic:masterfrom
Conversation
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.
ebinnion
requested changes
Dec 6, 2017
Contributor
ebinnion
left a comment
There was a problem hiding this comment.
This tests well. I left a few comments about coding standards. Besides that, LGTM though.
modules/lazy-images/lazy-images.php
Outdated
| 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 ); |
Contributor
There was a problem hiding this comment.
Nitpick, but could you please add a space between array( and $this.
modules/lazy-images/lazy-images.php
Outdated
| 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); |
Contributor
There was a problem hiding this comment.
Also, would you add the space here between array( and $this please.
modules/lazy-images/lazy-images.php
Outdated
| 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 ); |
Contributor
There was a problem hiding this comment.
Same with this line and the one below it.
fixed spacing issues.
Contributor
Author
|
I fixed the spacing issues highlighted by @ebinnion |
ebinnion
approved these changes
Dec 7, 2017
Contributor
|
@Volnus can you rebase this branch. There are some conflicts now. Thanks! I'm relabeling as needs review. |
zinigor
approved these changes
Jan 29, 2018
Contributor
zinigor
left a comment
There was a problem hiding this comment.
Fixed conflicts, should be ready to merge now.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: