1818 * images to avoid making individual database calls. |
1819 * images to avoid making individual database calls. |
1819 */ |
1820 */ |
1820 _prime_post_caches( $attachment_ids, false, true ); |
1821 _prime_post_caches( $attachment_ids, false, true ); |
1821 } |
1822 } |
1822 |
1823 |
1823 foreach ( $images as $image => $attachment_id ) { |
1824 // Iterate through the matches in order of occurrence as it is relevant for whether or not to lazy-load. |
1824 $filtered_image = $image; |
1825 foreach ( $matches as $match ) { |
1825 |
1826 // Filter an image match. |
1826 // Add 'width' and 'height' attributes if applicable. |
1827 if ( isset( $images[ $match[0] ] ) ) { |
1827 if ( $attachment_id > 0 && false === strpos( $filtered_image, ' width=' ) && false === strpos( $filtered_image, ' height=' ) ) { |
1828 $filtered_image = $match[0]; |
1828 $filtered_image = wp_img_tag_add_width_and_height_attr( $filtered_image, $context, $attachment_id ); |
1829 $attachment_id = $images[ $match[0] ]; |
1829 } |
1830 |
1830 |
1831 // Add 'width' and 'height' attributes if applicable. |
1831 // Add 'srcset' and 'sizes' attributes if applicable. |
1832 if ( $attachment_id > 0 && false === strpos( $filtered_image, ' width=' ) && false === strpos( $filtered_image, ' height=' ) ) { |
1832 if ( $attachment_id > 0 && false === strpos( $filtered_image, ' srcset=' ) ) { |
1833 $filtered_image = wp_img_tag_add_width_and_height_attr( $filtered_image, $context, $attachment_id ); |
1833 $filtered_image = wp_img_tag_add_srcset_and_sizes_attr( $filtered_image, $context, $attachment_id ); |
1834 } |
1834 } |
1835 |
1835 |
1836 // Add 'srcset' and 'sizes' attributes if applicable. |
1836 // Add 'loading' attribute if applicable. |
1837 if ( $attachment_id > 0 && false === strpos( $filtered_image, ' srcset=' ) ) { |
1837 if ( $add_img_loading_attr && false === strpos( $filtered_image, ' loading=' ) ) { |
1838 $filtered_image = wp_img_tag_add_srcset_and_sizes_attr( $filtered_image, $context, $attachment_id ); |
1838 $filtered_image = wp_img_tag_add_loading_attr( $filtered_image, $context ); |
1839 } |
1839 } |
1840 |
1840 |
1841 // Add 'loading' attribute if applicable. |
1841 if ( $filtered_image !== $image ) { |
1842 if ( $add_img_loading_attr && false === strpos( $filtered_image, ' loading=' ) ) { |
1842 $content = str_replace( $image, $filtered_image, $content ); |
1843 $filtered_image = wp_img_tag_add_loading_attr( $filtered_image, $context ); |
1843 } |
1844 } |
1844 } |
1845 |
1845 |
1846 /** |
1846 foreach ( $iframes as $iframe => $attachment_id ) { |
1847 * Filters an img tag within the content for a given context. |
1847 $filtered_iframe = $iframe; |
1848 * |
1848 |
1849 * @since 6.0.0 |
1849 // Add 'loading' attribute if applicable. |
1850 * |
1850 if ( $add_iframe_loading_attr && false === strpos( $filtered_iframe, ' loading=' ) ) { |
1851 * @param string $filtered_image Full img tag with attributes that will replace the source img tag. |
1851 $filtered_iframe = wp_iframe_tag_add_loading_attr( $filtered_iframe, $context ); |
1852 * @param string $context Additional context, like the current filter name or the function name from where this was called. |
1852 } |
1853 * @param int $attachment_id The image attachment ID. May be 0 in case the image is not an attachment. |
1853 |
1854 */ |
1854 if ( $filtered_iframe !== $iframe ) { |
1855 $filtered_image = apply_filters( 'wp_content_img_tag', $filtered_image, $context, $attachment_id ); |
1855 $content = str_replace( $iframe, $filtered_iframe, $content ); |
1856 |
|
1857 if ( $filtered_image !== $match[0] ) { |
|
1858 $content = str_replace( $match[0], $filtered_image, $content ); |
|
1859 } |
|
1860 |
|
1861 /* |
|
1862 * Unset image lookup to not run the same logic again unnecessarily if the same image tag is used more than |
|
1863 * once in the same blob of content. |
|
1864 */ |
|
1865 unset( $images[ $match[0] ] ); |
|
1866 } |
|
1867 |
|
1868 // Filter an iframe match. |
|
1869 if ( isset( $iframes[ $match[0] ] ) ) { |
|
1870 $filtered_iframe = $match[0]; |
|
1871 |
|
1872 // Add 'loading' attribute if applicable. |
|
1873 if ( $add_iframe_loading_attr && false === strpos( $filtered_iframe, ' loading=' ) ) { |
|
1874 $filtered_iframe = wp_iframe_tag_add_loading_attr( $filtered_iframe, $context ); |
|
1875 } |
|
1876 |
|
1877 if ( $filtered_iframe !== $match[0] ) { |
|
1878 $content = str_replace( $match[0], $filtered_iframe, $content ); |
|
1879 } |
|
1880 |
|
1881 /* |
|
1882 * Unset iframe lookup to not run the same logic again unnecessarily if the same iframe tag is used more |
|
1883 * than once in the same blob of content. |
|
1884 */ |
|
1885 unset( $iframes[ $match[0] ] ); |
1856 } |
1886 } |
1857 } |
1887 } |
1858 |
1888 |
1859 return $content; |
1889 return $content; |
1860 } |
1890 } |
2095 * 'aligncenter', alignright', 'alignnone'. |
2134 * 'aligncenter', alignright', 'alignnone'. |
2096 * @type int $width The width of the caption, in pixels. |
2135 * @type int $width The width of the caption, in pixels. |
2097 * @type string $caption The caption text. |
2136 * @type string $caption The caption text. |
2098 * @type string $class Additional class name(s) added to the caption container. |
2137 * @type string $class Additional class name(s) added to the caption container. |
2099 * } |
2138 * } |
2100 * @param string $content Shortcode content. |
2139 * @param string $content Optional. Shortcode content. Default empty string. |
2101 * @return string HTML content to display the caption. |
2140 * @return string HTML content to display the caption. |
2102 */ |
2141 */ |
2103 function img_caption_shortcode( $attr, $content = null ) { |
2142 function img_caption_shortcode( $attr, $content = '' ) { |
2104 // New-style shortcode with the caption inside the shortcode with the link and image tags. |
2143 // New-style shortcode with the caption inside the shortcode with the link and image tags. |
2105 if ( ! isset( $attr['caption'] ) ) { |
2144 if ( ! isset( $attr['caption'] ) ) { |
2106 if ( preg_match( '#((?:<a [^>]+>\s*)?<img [^>]+>(?:\s*</a>)?)(.*)#is', $content, $matches ) ) { |
2145 if ( preg_match( '#((?:<a [^>]+>\s*)?<img [^>]+>(?:\s*</a>)?)(.*)#is', $content, $matches ) ) { |
2107 $content = $matches[1]; |
2146 $content = $matches[1]; |
2108 $attr['caption'] = trim( $matches[2] ); |
2147 $attr['caption'] = trim( $matches[2] ); |
4453 'returnToLibrary' => __( '← Go to library' ), |
4492 'returnToLibrary' => __( '← Go to library' ), |
4454 'allMediaItems' => __( 'All media items' ), |
4493 'allMediaItems' => __( 'All media items' ), |
4455 'allDates' => __( 'All dates' ), |
4494 'allDates' => __( 'All dates' ), |
4456 'noItemsFound' => __( 'No items found.' ), |
4495 'noItemsFound' => __( 'No items found.' ), |
4457 'insertIntoPost' => $post_type_object->labels->insert_into_item, |
4496 'insertIntoPost' => $post_type_object->labels->insert_into_item, |
4458 'unattached' => __( 'Unattached' ), |
4497 'unattached' => _x( 'Unattached', 'media items' ), |
4459 'mine' => _x( 'Mine', 'media items' ), |
4498 'mine' => _x( 'Mine', 'media items' ), |
4460 'trash' => _x( 'Trash', 'noun' ), |
4499 'trash' => _x( 'Trash', 'noun' ), |
4461 'uploadedToThisPost' => $post_type_object->labels->uploaded_to_this_item, |
4500 'uploadedToThisPost' => $post_type_object->labels->uploaded_to_this_item, |
4462 'warnDelete' => __( "You are about to permanently delete this item from your site.\nThis action cannot be undone.\n 'Cancel' to stop, 'OK' to delete." ), |
4501 'warnDelete' => __( "You are about to permanently delete this item from your site.\nThis action cannot be undone.\n 'Cancel' to stop, 'OK' to delete." ), |
4463 'warnBulkDelete' => __( "You are about to permanently delete these items from your site.\nThis action cannot be undone.\n 'Cancel' to stop, 'OK' to delete." ), |
4502 'warnBulkDelete' => __( "You are about to permanently delete these items from your site.\nThis action cannot be undone.\n 'Cancel' to stop, 'OK' to delete." ), |
4464 'warnBulkTrash' => __( "You are about to trash these items.\n 'Cancel' to stop, 'OK' to delete." ), |
4503 'warnBulkTrash' => __( "You are about to trash these items.\n 'Cancel' to stop, 'OK' to delete." ), |
4465 'bulkSelect' => __( 'Bulk select' ), |
4504 'bulkSelect' => __( 'Bulk select' ), |
4466 'trashSelected' => __( 'Move to Trash' ), |
4505 'trashSelected' => __( 'Move to Trash' ), |
4467 'restoreSelected' => __( 'Restore from Trash' ), |
4506 'restoreSelected' => __( 'Restore from Trash' ), |
4468 'deletePermanently' => __( 'Delete permanently' ), |
4507 'deletePermanently' => __( 'Delete permanently' ), |
|
4508 'errorDeleting' => __( 'Error in deleting the attachment.' ), |
4469 'apply' => __( 'Apply' ), |
4509 'apply' => __( 'Apply' ), |
4470 'filterByDate' => __( 'Filter by date' ), |
4510 'filterByDate' => __( 'Filter by date' ), |
4471 'filterByType' => __( 'Filter by type' ), |
4511 'filterByType' => __( 'Filter by type' ), |
4472 'searchLabel' => __( 'Search' ), |
4512 'searchLabel' => __( 'Search' ), |
4473 'searchMediaLabel' => __( 'Search media' ), // Backward compatibility pre-5.3. |
4513 'searchMediaLabel' => __( 'Search media' ), // Backward compatibility pre-5.3. |
4747 'src' => array_values( array_unique( $srcs ) ), |
4787 'src' => array_values( array_unique( $srcs ) ), |
4748 ) |
4788 ) |
4749 ); |
4789 ); |
4750 } |
4790 } |
4751 } |
4791 } |
|
4792 } |
|
4793 } |
|
4794 |
|
4795 if ( has_block( 'gallery', $post->post_content ) ) { |
|
4796 $post_blocks = parse_blocks( $post->post_content ); |
|
4797 |
|
4798 while ( $block = array_shift( $post_blocks ) ) { |
|
4799 $has_inner_blocks = ! empty( $block['innerBlocks'] ); |
|
4800 |
|
4801 // Skip blocks with no blockName and no innerHTML. |
|
4802 if ( ! $block['blockName'] ) { |
|
4803 continue; |
|
4804 } |
|
4805 |
|
4806 // Skip non-Gallery blocks. |
|
4807 if ( 'core/gallery' !== $block['blockName'] ) { |
|
4808 // Move inner blocks into the root array before skipping. |
|
4809 if ( $has_inner_blocks ) { |
|
4810 array_push( $post_blocks, ...$block['innerBlocks'] ); |
|
4811 } |
|
4812 continue; |
|
4813 } |
|
4814 |
|
4815 // New Gallery block format as HTML. |
|
4816 if ( $has_inner_blocks && $html ) { |
|
4817 $block_html = wp_list_pluck( $block['innerBlocks'], 'innerHTML' ); |
|
4818 $galleries[] = '<figure>' . implode( ' ', $block_html ) . '</figure>'; |
|
4819 continue; |
|
4820 } |
|
4821 |
|
4822 $srcs = array(); |
|
4823 |
|
4824 // New Gallery block format as an array. |
|
4825 if ( $has_inner_blocks ) { |
|
4826 $attrs = wp_list_pluck( $block['innerBlocks'], 'attrs' ); |
|
4827 $ids = wp_list_pluck( $attrs, 'id' ); |
|
4828 |
|
4829 foreach ( $ids as $id ) { |
|
4830 $url = wp_get_attachment_url( $id ); |
|
4831 |
|
4832 if ( is_string( $url ) && ! in_array( $url, $srcs, true ) ) { |
|
4833 $srcs[] = $url; |
|
4834 } |
|
4835 } |
|
4836 |
|
4837 $galleries[] = array( |
|
4838 'ids' => implode( ',', $ids ), |
|
4839 'src' => $srcs, |
|
4840 ); |
|
4841 |
|
4842 continue; |
|
4843 } |
|
4844 |
|
4845 // Old Gallery block format as HTML. |
|
4846 if ( $html ) { |
|
4847 $galleries[] = $block['innerHTML']; |
|
4848 continue; |
|
4849 } |
|
4850 |
|
4851 // Old Gallery block format as an array. |
|
4852 $ids = ! empty( $block['attrs']['ids'] ) ? $block['attrs']['ids'] : array(); |
|
4853 |
|
4854 // If present, use the image IDs from the JSON blob as canonical. |
|
4855 if ( ! empty( $ids ) ) { |
|
4856 foreach ( $ids as $id ) { |
|
4857 $url = wp_get_attachment_url( $id ); |
|
4858 |
|
4859 if ( is_string( $url ) && ! in_array( $url, $srcs, true ) ) { |
|
4860 $srcs[] = $url; |
|
4861 } |
|
4862 } |
|
4863 |
|
4864 $galleries[] = array( |
|
4865 'ids' => implode( ',', $ids ), |
|
4866 'src' => $srcs, |
|
4867 ); |
|
4868 |
|
4869 continue; |
|
4870 } |
|
4871 |
|
4872 // Otherwise, extract srcs from the innerHTML. |
|
4873 preg_match_all( '#src=([\'"])(.+?)\1#is', $block['innerHTML'], $found_srcs, PREG_SET_ORDER ); |
|
4874 |
|
4875 if ( ! empty( $found_srcs[0] ) ) { |
|
4876 foreach ( $found_srcs as $src ) { |
|
4877 if ( isset( $src[2] ) && ! in_array( $src[2], $srcs, true ) ) { |
|
4878 $srcs[] = $src[2]; |
|
4879 } |
|
4880 } |
|
4881 } |
|
4882 |
|
4883 $galleries[] = array( 'src' => $srcs ); |
4752 } |
4884 } |
4753 } |
4885 } |
4754 |
4886 |
4755 /** |
4887 /** |
4756 * Filters the list of all found galleries in the given post. |
4888 * Filters the list of all found galleries in the given post. |
5105 // The image could not be parsed. |
5237 // The image could not be parsed. |
5106 return false; |
5238 return false; |
5107 } |
5239 } |
5108 |
5240 |
5109 /** |
5241 /** |
5110 * Extracts meta information about a webp file: width, height and type. |
5242 * Extracts meta information about a WebP file: width, height, and type. |
5111 * |
5243 * |
5112 * @since 5.8.0 |
5244 * @since 5.8.0 |
5113 * |
5245 * |
5114 * @param string $filename Path to a WebP file. |
5246 * @param string $filename Path to a WebP file. |
5115 * @return array $webp_info { |
5247 * @return array { |
5116 * An array of WebP image information. |
5248 * An array of WebP image information. |
5117 * |
5249 * |
5118 * @type array $size { |
5250 * @type int|false $width Image width on success, false on failure. |
5119 * @type int|false $width Image width on success, false on failure. |
5251 * @type int|false $height Image height on success, false on failure. |
5120 * @type int|false $height Image height on success, false on failure. |
5252 * @type string|false $type The WebP type: one of 'lossy', 'lossless' or 'animated-alpha'. |
5121 * @type string|false $type The WebP type: one of 'lossy', 'lossless' or 'animated-alpha'. |
5253 * False on failure. |
5122 * False on failure. |
5254 * } |
5123 * } |
|
5124 */ |
5255 */ |
5125 function wp_get_webp_info( $filename ) { |
5256 function wp_get_webp_info( $filename ) { |
5126 $width = false; |
5257 $width = false; |
5127 $height = false; |
5258 $height = false; |
5128 $type = false; |
5259 $type = false; |
5129 |
5260 |
5130 if ( 'image/webp' !== wp_get_image_mime( $filename ) ) { |
5261 if ( 'image/webp' !== wp_get_image_mime( $filename ) ) { |
5131 return compact( 'width', 'height', 'type' ); |
5262 return compact( 'width', 'height', 'type' ); |
5132 } |
5263 } |
5133 |
5264 |
5134 try { |
5265 $magic = file_get_contents( $filename, false, null, 0, 40 ); |
5135 $handle = fopen( $filename, 'rb' ); |
5266 |
5136 if ( $handle ) { |
5267 if ( false === $magic ) { |
5137 $magic = fread( $handle, 40 ); |
5268 return compact( 'width', 'height', 'type' ); |
5138 fclose( $handle ); |
5269 } |
5139 |
5270 |
5140 // Make sure we got enough bytes. |
5271 // Make sure we got enough bytes. |
5141 if ( strlen( $magic ) < 40 ) { |
5272 if ( strlen( $magic ) < 40 ) { |
5142 return compact( 'width', 'height', 'type' ); |
5273 return compact( 'width', 'height', 'type' ); |
5143 } |
5274 } |
5144 |
5275 |
5145 // The headers are a little different for each of the three formats. |
5276 // The headers are a little different for each of the three formats. |
5146 // Header values based on WebP docs, see https://developers.google.com/speed/webp/docs/riff_container. |
5277 // Header values based on WebP docs, see https://developers.google.com/speed/webp/docs/riff_container. |
5147 switch ( substr( $magic, 12, 4 ) ) { |
5278 switch ( substr( $magic, 12, 4 ) ) { |
5148 // Lossy WebP. |
5279 // Lossy WebP. |
5149 case 'VP8 ': |
5280 case 'VP8 ': |
5150 $parts = unpack( 'v2', substr( $magic, 26, 4 ) ); |
5281 $parts = unpack( 'v2', substr( $magic, 26, 4 ) ); |
5151 $width = (int) ( $parts[1] & 0x3FFF ); |
5282 $width = (int) ( $parts[1] & 0x3FFF ); |
5152 $height = (int) ( $parts[2] & 0x3FFF ); |
5283 $height = (int) ( $parts[2] & 0x3FFF ); |
5153 $type = 'lossy'; |
5284 $type = 'lossy'; |
5154 break; |
5285 break; |
5155 // Lossless WebP. |
5286 // Lossless WebP. |
5156 case 'VP8L': |
5287 case 'VP8L': |
5157 $parts = unpack( 'C4', substr( $magic, 21, 4 ) ); |
5288 $parts = unpack( 'C4', substr( $magic, 21, 4 ) ); |
5158 $width = (int) ( $parts[1] | ( ( $parts[2] & 0x3F ) << 8 ) ) + 1; |
5289 $width = (int) ( $parts[1] | ( ( $parts[2] & 0x3F ) << 8 ) ) + 1; |
5159 $height = (int) ( ( ( $parts[2] & 0xC0 ) >> 6 ) | ( $parts[3] << 2 ) | ( ( $parts[4] & 0x03 ) << 10 ) ) + 1; |
5290 $height = (int) ( ( ( $parts[2] & 0xC0 ) >> 6 ) | ( $parts[3] << 2 ) | ( ( $parts[4] & 0x03 ) << 10 ) ) + 1; |
5160 $type = 'lossless'; |
5291 $type = 'lossless'; |
5161 break; |
5292 break; |
5162 // Animated/alpha WebP. |
5293 // Animated/alpha WebP. |
5163 case 'VP8X': |
5294 case 'VP8X': |
5164 // Pad 24-bit int. |
5295 // Pad 24-bit int. |
5165 $width = unpack( 'V', substr( $magic, 24, 3 ) . "\x00" ); |
5296 $width = unpack( 'V', substr( $magic, 24, 3 ) . "\x00" ); |
5166 $width = (int) ( $width[1] & 0xFFFFFF ) + 1; |
5297 $width = (int) ( $width[1] & 0xFFFFFF ) + 1; |
5167 // Pad 24-bit int. |
5298 // Pad 24-bit int. |
5168 $height = unpack( 'V', substr( $magic, 27, 3 ) . "\x00" ); |
5299 $height = unpack( 'V', substr( $magic, 27, 3 ) . "\x00" ); |
5169 $height = (int) ( $height[1] & 0xFFFFFF ) + 1; |
5300 $height = (int) ( $height[1] & 0xFFFFFF ) + 1; |
5170 $type = 'animated-alpha'; |
5301 $type = 'animated-alpha'; |
5171 break; |
5302 break; |
5172 } |
|
5173 } |
|
5174 } catch ( Exception $e ) { |
|
5175 } |
5303 } |
5176 |
5304 |
5177 return compact( 'width', 'height', 'type' ); |
5305 return compact( 'width', 'height', 'type' ); |
5178 } |
5306 } |
|
5307 |
|
5308 /** |
|
5309 * Gets the default value to use for a `loading` attribute on an element. |
|
5310 * |
|
5311 * This function should only be called for a tag and context if lazy-loading is generally enabled. |
|
5312 * |
|
5313 * The function usually returns 'lazy', but uses certain heuristics to guess whether the current element is likely to |
|
5314 * appear above the fold, in which case it returns a boolean `false`, which will lead to the `loading` attribute being |
|
5315 * omitted on the element. The purpose of this refinement is to avoid lazy-loading elements that are within the initial |
|
5316 * viewport, which can have a negative performance impact. |
|
5317 * |
|
5318 * Under the hood, the function uses {@see wp_increase_content_media_count()} every time it is called for an element |
|
5319 * within the main content. If the element is the very first content element, the `loading` attribute will be omitted. |
|
5320 * This default threshold of 1 content element to omit the `loading` attribute for can be customized using the |
|
5321 * {@see 'wp_omit_loading_attr_threshold'} filter. |
|
5322 * |
|
5323 * @since 5.9.0 |
|
5324 * |
|
5325 * @param string $context Context for the element for which the `loading` attribute value is requested. |
|
5326 * @return string|bool The default `loading` attribute value. Either 'lazy', 'eager', or a boolean `false`, to indicate |
|
5327 * that the `loading` attribute should be skipped. |
|
5328 */ |
|
5329 function wp_get_loading_attr_default( $context ) { |
|
5330 // Only elements with 'the_content' or 'the_post_thumbnail' context have special handling. |
|
5331 if ( 'the_content' !== $context && 'the_post_thumbnail' !== $context ) { |
|
5332 return 'lazy'; |
|
5333 } |
|
5334 |
|
5335 // Only elements within the main query loop have special handling. |
|
5336 if ( is_admin() || ! in_the_loop() || ! is_main_query() ) { |
|
5337 return 'lazy'; |
|
5338 } |
|
5339 |
|
5340 // Increase the counter since this is a main query content element. |
|
5341 $content_media_count = wp_increase_content_media_count(); |
|
5342 |
|
5343 // If the count so far is below the threshold, return `false` so that the `loading` attribute is omitted. |
|
5344 if ( $content_media_count <= wp_omit_loading_attr_threshold() ) { |
|
5345 return false; |
|
5346 } |
|
5347 |
|
5348 // For elements after the threshold, lazy-load them as usual. |
|
5349 return 'lazy'; |
|
5350 } |
|
5351 |
|
5352 /** |
|
5353 * Gets the threshold for how many of the first content media elements to not lazy-load. |
|
5354 * |
|
5355 * This function runs the {@see 'wp_omit_loading_attr_threshold'} filter, which uses a default threshold value of 1. |
|
5356 * The filter is only run once per page load, unless the `$force` parameter is used. |
|
5357 * |
|
5358 * @since 5.9.0 |
|
5359 * |
|
5360 * @param bool $force Optional. If set to true, the filter will be (re-)applied even if it already has been before. |
|
5361 * Default false. |
|
5362 * @return int The number of content media elements to not lazy-load. |
|
5363 */ |
|
5364 function wp_omit_loading_attr_threshold( $force = false ) { |
|
5365 static $omit_threshold; |
|
5366 |
|
5367 // This function may be called multiple times. Run the filter only once per page load. |
|
5368 if ( ! isset( $omit_threshold ) || $force ) { |
|
5369 /** |
|
5370 * Filters the threshold for how many of the first content media elements to not lazy-load. |
|
5371 * |
|
5372 * For these first content media elements, the `loading` attribute will be omitted. By default, this is the case |
|
5373 * for only the very first content media element. |
|
5374 * |
|
5375 * @since 5.9.0 |
|
5376 * |
|
5377 * @param int $omit_threshold The number of media elements where the `loading` attribute will not be added. Default 1. |
|
5378 */ |
|
5379 $omit_threshold = apply_filters( 'wp_omit_loading_attr_threshold', 1 ); |
|
5380 } |
|
5381 |
|
5382 return $omit_threshold; |
|
5383 } |
|
5384 |
|
5385 /** |
|
5386 * Increases an internal content media count variable. |
|
5387 * |
|
5388 * @since 5.9.0 |
|
5389 * @access private |
|
5390 * |
|
5391 * @param int $amount Optional. Amount to increase by. Default 1. |
|
5392 * @return int The latest content media count, after the increase. |
|
5393 */ |
|
5394 function wp_increase_content_media_count( $amount = 1 ) { |
|
5395 static $content_media_count = 0; |
|
5396 |
|
5397 $content_media_count += $amount; |
|
5398 |
|
5399 return $content_media_count; |
|
5400 } |