Felix Arntz
780b0399f7
Media: Refine the heuristics to exclude certain images and iframes from being lazy-loaded to improve performance.
...
This changeset implements the refined lazy-loading behavior outlined in https://make.wordpress.org/core/2021/07/15/refining-wordpress-cores-lazy-loading-implementation/ in order to improve the Largest Contentful Paint metric, which can see a regression from images or iframes above the fold being lazy-loaded. Adjusting this so far has been possible for developers via filters and still is, however this enhancement brings a more accurate behavior out of the box for the majority of themes.
Specifically, this changeset skips the very first "content image or iframe" on the page from being lazy-loaded. "Content image or iframe" denotes any image or iframe that is found within content of any post in the current main query loop as well as any featured image of such a post. This applies both to "singular" as well as "archive" content: On a "singular" page the first image/iframe of the post is not lazy-loaded, while on an "archive" page the first image/iframe of the _first_ post in the query is not lazy-loaded.
This approach refines the lazy-loading behavior correctly for the majority of themes, which use a single-column layout for post content. For themes with multi-column layouts, a new `wp_omit_loading_attr_threshold` filter can be used to change how many of the first images/iframes are being skipped from lazy-loaded (default is `1`). For example, a theme using a three-column grid of latest posts for archives could use the filter to override the threshold to `3` on archive pages, so that the first three content images/iframes would not be lazy-loaded.
Props adamsilverstein, azaozz, flixos90, hellofromtonya, jonoaldersonwp, mte90, rviscomi, tweetythierry, westonruter.
Fixes #53675 . See #50425 .
Built from https://develop.svn.wordpress.org/trunk@52065
git-svn-id: http://core.svn.wordpress.org/trunk@51657 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-11-09 00:36:01 +00:00
antpb
78d274099a
Media: Add filter for post thumbnail id.
...
Introduces new filter `post_thumbnail_id` which allows overriding the default id returned from `get_post_thumbnail_id()`.
Props engelen, alexvorn2, gilbitron, sebastianpisula, SergeyBiryukov, leogermani, rzen, joemcgill, audrasjb.
Fixes #23983 .
Built from https://develop.svn.wordpress.org/trunk@52028
git-svn-id: http://core.svn.wordpress.org/trunk@51620 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-11-07 20:37:58 +00:00
antpb
5df077df8a
Media: Add filter for post thumbnail url.
...
Introduces new filter `post_thumbnail_url` which allows overriding the default url returned from `wp_get_attachement_image_url()`.
Props ibenic, SergeyBiryukov, jackreichert, audrasjb.
Fixes #40547 .
Built from https://develop.svn.wordpress.org/trunk@52027
git-svn-id: http://core.svn.wordpress.org/trunk@51619 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-11-07 19:29:00 +00:00
Sergey Biryukov
8bc5c10684
Docs: Clarify the `@return` value for `wp_get_attachment_image_url()` and `get_the_post_thumbnail_url()`.
...
Props GeekPress, audrasjb, naveen17797.
Fixes #52183 .
Built from https://develop.svn.wordpress.org/trunk@50236
git-svn-id: http://core.svn.wordpress.org/trunk@49897 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-02-08 14:14:08 +00:00
John Blackbourn
f4cda1b62f
Docs: Upgrade more parameters in docblocks to used typed array notation.
...
See #51800 , #41756
Built from https://develop.svn.wordpress.org/trunk@49693
git-svn-id: http://core.svn.wordpress.org/trunk@49416 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-11-24 21:27:05 +00:00
John Blackbourn
aba2165aae
Media: Standardise the description for image size parameters.
...
This brings continuity to all the image related functions and filters which accept or pass a size parameter.
Props dilipbheda, johnbillion
Fixes #47364
Built from https://develop.svn.wordpress.org/trunk@49021
git-svn-id: http://core.svn.wordpress.org/trunk@48783 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-09-20 16:23:07 +00:00
John Blackbourn
e22107ce4e
Media: Correct some types in docblocks for filters related to thumbnails.
...
Props dilipbheda
See #47364 , #50768
Built from https://develop.svn.wordpress.org/trunk@49016
git-svn-id: http://core.svn.wordpress.org/trunk@48778 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-09-20 13:40:04 +00:00
Sergey Biryukov
9f92384fe7
Post Thumbnails: Change the return value of `get_post_thumbnail_id()` for a non-existing post to `false` instead of an empty string.
...
This further makes the function more consistent with `get_the_ID()` or `wp_get_post_parent_id()`, both returning `false` for a non-existing post.
Additionally, document that `get_post_thumbnail_id()` returns `0` if the thumbnail image is not set.
Follow-up to [47160].
Props theMikeD, dingo_d, netpassprodsr, SergeyBiryukov.
Fixes #49832 . See #40096 .
Built from https://develop.svn.wordpress.org/trunk@48310
git-svn-id: http://core.svn.wordpress.org/trunk@48079 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-05 10:17:02 +00:00
Sergey Biryukov
7e331ab235
Post Thumbnails: Make sure `get_post_thumbnail_id()` returns an integer, to match the documented return value.
...
This makes the function more consistent with `get_the_ID()` or `wp_get_post_parent_id()`, both returning an integer.
Props 0v3rth3d4wn.
Fixes #40096 .
Built from https://develop.svn.wordpress.org/trunk@47160
git-svn-id: http://core.svn.wordpress.org/trunk@46960 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-02-02 03:08:04 +00:00
Sergey Biryukov
7f7480cb2a
Docs: Add missing description for `$wp_query` and `$wp_the_query` globals.
...
Props mukesh27.
See #45604 , #47110 .
Built from https://develop.svn.wordpress.org/trunk@45739
git-svn-id: http://core.svn.wordpress.org/trunk@45550 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-08-04 01:59:56 +00:00
Gary Pendergast
4803fc405e
Coding Standards: Fix the `Squiz.PHP.DisallowMultipleAssignments` violations in `wp-includes`.
...
See #47632 .
Built from https://develop.svn.wordpress.org/trunk@45590
git-svn-id: http://core.svn.wordpress.org/trunk@45401 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-07-02 23:42:58 +00:00
desrosj
ae5c195d57
Media: Introduce the `has_post_thumbnail` filter.
...
Props rzen, desrosj.
Fixes #44859 .
Built from https://develop.svn.wordpress.org/trunk@44542
git-svn-id: http://core.svn.wordpress.org/trunk@44373 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-01-10 15:28:50 +00:00
Dominik Schilling
5c291d49de
Pinking shears.
...
See #41057 .
Built from https://develop.svn.wordpress.org/trunk@42843
git-svn-id: http://core.svn.wordpress.org/trunk@42673 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-03-18 14:23:33 +00:00
Drew Jaynes
6e665d1f15
Docs: Link to the "Conditional Tags" article in the Theme Developer Handbook from the descriptions for a variety of core conditional tag functions.
...
These notations largely serve to direct consumers (of both the source and the parsed code reference) to extended information on individual and related conditional tags throughout WordPress. The changeset also standardizes corresponding DocBlock summaries to use third-person singular verbs.
Notations been added for the following functions:
* comments_open()
* email exists()
* has_excerpt()
* has_post_thumbnail()
* has_tag()
* in_category()
* in_the_loop()
* is_404()
* is_active_sidebar()
* is_active_widget()
* is_admin()
* is_admin_bar_showing()
* is_archive()
* is_attachment()
* is_author()
* is_blog_installed()
* is_category()
* is_comments_popup()
* is_date()
* is_day()
* is_dynamic_sidebar()
* is_feed()
* is_front_page()
* is_home()
* is_local_attachment()
* is_main_query
* is_month()
* is_multi_author
* is_new_day()
* is_page()
* is_page_template()
* is_paged()
* is_plugin_active()
* is_plugin_active_for_network()
* is_plugin_inactive()
* is_plugin_page()
* is_post_type_archive()
* is_preview()
* is_rtl()
* is_search()
* is_single()
* is_singular()
* is_sticky()
* is_tag()
* is_tax()
* is_taxonomy_hierarchical()
* is_time()
* is_trackback()
* is_user_logged_in()
* is_year()
* pings_open()
* post_type_exists()
* taxonomy_exists()
* term_exists()
* username exists()
* wp_attachment_is_image()
* wp_script_is()
Props janalwin.
Fixes #43254 .
Built from https://develop.svn.wordpress.org/trunk@42710
git-svn-id: http://core.svn.wordpress.org/trunk@42538 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-02-13 16:54:31 +00:00
Gary Pendergast
aaf99e6913
Code is Poetry.
...
WordPress' code just... wasn't.
This is now dealt with.
Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057 .
Built from https://develop.svn.wordpress.org/trunk@42343
git-svn-id: http://core.svn.wordpress.org/trunk@42172 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-11-30 23:11:00 +00:00
Felix Arntz
c14e0a0527
Post Thumbnails: Pass post ID to `post_thumbnail_size` filter.
...
In addition to the enhancement, tests for the filter usage including the new parameter have been added.
Props NathanAtmoz.
Fixes #39030 .
Built from https://develop.svn.wordpress.org/trunk@41267
git-svn-id: http://core.svn.wordpress.org/trunk@41107 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-08-18 18:19:44 +00:00
Joe McGill
170d22a22c
Post Thumbnails: Add helper functions for attachment captions.
...
This adds three new functions for getting/displaying attachment captions:
* `wp_get_attachment_caption` - Retrieves a caption for a specific attachment.
* `get_the_post_thumbnail_caption()` - Returns the post thumbnail caption.
* `the_post_thumbnail_caption()` - Displays the post thumbnail caption.
These are helpful for displaying a caption associated with an image directly
in a template, rather than using the caption shortcode.
This also introduces two new filters:
* `wp_get_attachment_caption` - Filters the value of `wp_get_attachment_caption()`.
* `the_post_thumbnail_caption` - Filters the display of the post thumbnail caption.
`the_post_thumbnail_caption()` is automatically filtered by `wptexturize()`,
`convert_smilies()`, and `convert_chars()` in `wp-includes/default-filters.php`.
Props flixos90, joemcgill.
Fixes #12235 .
Built from https://develop.svn.wordpress.org/trunk@37915
git-svn-id: http://core.svn.wordpress.org/trunk@37856 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-06-29 17:28:28 +00:00
Drew Jaynes
1f231c7293
Docs: Standardize filter docs in wp-includes/post-thumbnail-template.php to use third-person singular verbs per the inline documentation standards for PHP.
...
See #36913 .
Built from https://develop.svn.wordpress.org/trunk@37502
git-svn-id: http://core.svn.wordpress.org/trunk@37470 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-22 18:29:27 +00:00
Drew Jaynes
bc631019d0
Docs: Adjust documentation for the `$size` parameter in `the_post_thumbnail_url()` to clarify the required order of width and height values when passing an array.
...
Fixes #34257 . Whew!
Built from https://develop.svn.wordpress.org/trunk@35076
git-svn-id: http://core.svn.wordpress.org/trunk@35041 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-12 17:00:26 +00:00
Drew Jaynes
5e67b71443
Docs: The `post_thumbnail_size` hook can also accept an array (already supported).
...
See #34257 . See [35069].
Built from https://develop.svn.wordpress.org/trunk@35075
git-svn-id: http://core.svn.wordpress.org/trunk@35040 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-12 16:57:24 +00:00
Drew Jaynes
03a39f75b3
Docs: The `$size` parameters in the `begin_fetch_post_thumbnail_html` and `end_fetch_post_thumbnail_html` hooks can also accept an array (already supported).
...
See #34257 . See #32246 . See [35070] and [35071].
Built from https://develop.svn.wordpress.org/trunk@35074
git-svn-id: http://core.svn.wordpress.org/trunk@35039 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-12 16:56:24 +00:00
Drew Jaynes
dcb18faab8
Docs: Normalize spacing in the `post_thumbnail_html` hook doc following [35072].
...
See #34257 . See #32246 .
Built from https://develop.svn.wordpress.org/trunk@35073
git-svn-id: http://core.svn.wordpress.org/trunk@35038 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-12 16:53:24 +00:00
Drew Jaynes
476655b0e0
Docs: Adjust documentation for the `$size` parameter in the `post_thumbnail_html` hook doc to clarify the required order of width and height values when an array is passed.
...
Also adds the `array` type to the parameter documentation (already supported).
See #34257 .
Built from https://develop.svn.wordpress.org/trunk@35072
git-svn-id: http://core.svn.wordpress.org/trunk@35037 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-12 16:52:24 +00:00
Drew Jaynes
1564eb43b4
Docs: Adjust documentation for the `$size` parameter in the `end_fetch_post_thumbnail_html` hook doc to clarify the required order of width and height values when an array is passed.
...
See #34257 .
Built from https://develop.svn.wordpress.org/trunk@35071
git-svn-id: http://core.svn.wordpress.org/trunk@35036 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-12 16:50:25 +00:00
Drew Jaynes
91d5909507
Docs: Adjust documentation for the `$size` parameter in the `begin_fetch_post_thumbnail_html` hook doc to clarify the required order of width and height values when an array is passed.
...
See #34257 .
Built from https://develop.svn.wordpress.org/trunk@35070
git-svn-id: http://core.svn.wordpress.org/trunk@35035 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-12 16:49:24 +00:00
Drew Jaynes
fe0d59a061
Docs: Adjust documentation for the `$size` parameter in the `post_thumbnail_size` hook doc to clarify the required order of width and height values when an array is passed.
...
See #34257 .
Built from https://develop.svn.wordpress.org/trunk@35069
git-svn-id: http://core.svn.wordpress.org/trunk@35034 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-12 16:48:25 +00:00
Drew Jaynes
2091ff358d
Docs: Adjust documentation for the `$size` parameter in `get_the_post_thumbnail()` to clarify the required order of width and height values when passing an array.
...
See #34257 .
Built from https://develop.svn.wordpress.org/trunk@35068
git-svn-id: http://core.svn.wordpress.org/trunk@35033 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-12 16:47:25 +00:00
Drew Jaynes
2519b20959
Docs: Adjust documentation for the `$size` parameter in `the_post_thumbnail()` to clarify the required order of width and height values when passing an array.
...
See #34257 .
Built from https://develop.svn.wordpress.org/trunk@35067
git-svn-id: http://core.svn.wordpress.org/trunk@35032 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-12 16:46:24 +00:00
John Blackbourn
2a8abfef81
Update `get_the_post_thumbnail_url()` so it returns false on failure, to bring it inline with `wp_get_attachment_image_url()`. Correct and introduce new tests.
...
Fixes #33070
Built from https://develop.svn.wordpress.org/trunk@34663
git-svn-id: http://core.svn.wordpress.org/trunk@34627 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-28 15:34:25 +00:00
Scott Taylor
4e9c1692b0
Post Thumbnails: In `get_the_post_thumbnail_url()`, return `false` instead of empty string when no URL is available.
...
Fixes #33070 .
Built from https://develop.svn.wordpress.org/trunk@34480
git-svn-id: http://core.svn.wordpress.org/trunk@34444 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-24 04:38:25 +00:00
Scott Taylor
e3fcbf5d55
Media: Add new functions, `get_the_post_thumbnail_url()` and `the_post_thumbnail_url()`.
...
Adds unit tests.
Props dipesh.kakadiya, swissspidy, atomicjack.
Fixes #33070 .
Built from https://develop.svn.wordpress.org/trunk@34373
git-svn-id: http://core.svn.wordpress.org/trunk@34337 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-22 04:15:24 +00:00
Scott Taylor
ed25b09942
Update post thumbnail functions to allow a `WP_Post` to be passed.
...
Adds unit tests.
Props swissspidy, Rahe.
Fixes #33723 .
Built from https://develop.svn.wordpress.org/trunk@34167
git-svn-id: http://core.svn.wordpress.org/trunk@34135 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-15 03:46:25 +00:00
Scott Taylor
2f75a74b3e
Add missing doc blocks to `post-thumbnail-template.php`.
...
See #32444 .
Built from https://develop.svn.wordpress.org/trunk@32618
git-svn-id: http://core.svn.wordpress.org/trunk@32588 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-27 16:29:28 +00:00
Drew Jaynes
2e1ebd7b97
Adjust DocBlocks for `get_|the_post_thumbnail()` to clarify the difference between the 'thumbnail' and 'post-thumbnail' image sizes.
...
Also fleshes out parameter documentation for the two functions.
Props magicroundabout for the initial patch.
Fixes #31351 .
Built from https://develop.svn.wordpress.org/trunk@31853
git-svn-id: http://core.svn.wordpress.org/trunk@31832 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-03-20 19:57:26 +00:00
Sergey Biryukov
05f1506d93
A couple more tweaks to the post-thumbnail-template.php description.
...
see #30867 .
Built from https://develop.svn.wordpress.org/trunk@31048
git-svn-id: http://core.svn.wordpress.org/trunk@31029 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-04 23:10:21 +00:00
Scott Taylor
7f94333084
Correct a typo in `wp-includes/post-thumbnail-template.php`.
...
Props ixkaito.
Fixes #30867 .
Built from https://develop.svn.wordpress.org/trunk@31011
git-svn-id: http://core.svn.wordpress.org/trunk@30992 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-12-31 18:09:25 +00:00
Andrew Nacin
52cc239578
Revert [27166].
...
We should not be accounting for improper assignment of WP_Query properties.
fixes #26321 .
Built from https://develop.svn.wordpress.org/trunk@27746
git-svn-id: http://core.svn.wordpress.org/trunk@27583 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-03-26 18:43:14 +00:00
Scott Taylor
95243d2106
Don't iterate over `$wp_query->posts` in `update_post_thumbnail_cache()` if it is empty. Adds unit tests.
...
Props SergeyBiryukov, for the original patch.
Fixes #26321 .
Built from https://develop.svn.wordpress.org/trunk@27166
git-svn-id: http://core.svn.wordpress.org/trunk@27032 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-02-12 04:49:15 +00:00
Drew Jaynes
cd8cedc40d
First there were two, and now there are three -- in the @since versions that came before and that shall be. And so it will be, says nacin.
...
Props JustinSainton, SergeyBiryukov, DrewAPicture.
Fixes #26713 .
Built from https://develop.svn.wordpress.org/trunk@26868
git-svn-id: http://core.svn.wordpress.org/trunk@26754 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-24 18:57:12 +00:00
Drew Jaynes
69d9c3e427
Inline documentation for hooks in wp-includes/post-thumbnail-template.php.
...
Props NikV.
See #25229 .
Built from https://develop.svn.wordpress.org/trunk@25513
git-svn-id: http://core.svn.wordpress.org/trunk@25433 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-20 02:51:09 +00:00
Mark Jaquith
78d6345d88
Fix the PHPDoc for the_post_thumbnail(). props georgestephanis. fixes #22885
...
git-svn-id: http://core.svn.wordpress.org/trunk@23227 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-12-29 17:59:08 +00:00
nacin
89da6ded3b
Add $wp_query parameter to update_post_thumbnail_cache(). props scribu. see #19949 , fixes that ticket for 3.4.
...
git-svn-id: http://svn.automattic.com/wordpress/trunk@20646 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-04-30 15:55:57 +00:00
ryan
6aedd9d0f0
Split the main WP_Query posts query into two queries to avoid temp tables. Leverage cache to avoid second query in persistent cache environments. Props scribu, cheald, prettyboymp. see #18536
...
git-svn-id: http://svn.automattic.com/wordpress/trunk@19918 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-02-14 15:09:35 +00:00
nacin
68feb8ef19
s/thumbnail/post-thumbnail/. props PeteMall, fixes #19804 .
...
git-svn-id: http://svn.automattic.com/wordpress/trunk@19750 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-01-25 00:21:02 +00:00
ryan
e3b46b25d3
Lose EOF ?>. Clean up EOF newlines. fixes #12307
...
git-svn-id: http://svn.automattic.com/wordpress/trunk@19712 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-01-08 17:01:11 +00:00
ryan
07ff8b216b
Use one space, not two, after trailing punctuation. fixes #19537
...
git-svn-id: http://svn.automattic.com/wordpress/trunk@19593 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-12-13 23:45:31 +00:00
nacin
eb24f35c22
Pass $post_id arg directly to get_post_thumbnail_id() from has_post_thumbnail(). The null/get_the_ID() check is already performed at that level of the stack. see #19012 .
...
git-svn-id: http://svn.automattic.com/wordpress/trunk@19029 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-10-20 15:11:49 +00:00
ryan
32e25b6aec
phpdoc typo and readability fixes. Props SergeyBiryukov. fixes #18560
...
git-svn-id: http://svn.automattic.com/wordpress/trunk@18827 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-09-29 22:57:43 +00:00
nacin
70a4181fc7
Cache post thumbnails in the loop. props garyc40, scribu, greuben. fixes #15447 .
...
git-svn-id: http://svn.automattic.com/wordpress/trunk@17883 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-05-12 03:06:03 +00:00
nacin
d1093ac706
More pedantry.
...
git-svn-id: http://svn.automattic.com/wordpress/trunk@15990 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2010-10-27 00:33:29 +00:00