| 1 |
<?php |
| 2 |
/** |
| 3 |
* Hook callbacks used for Enhanced Responsive Images. |
| 4 |
* |
| 5 |
* @package auto-sizes |
| 6 |
* @since 1.0.0 |
| 7 |
*/ |
| 8 |
|
| 9 |
declare( strict_types = 1 ); |
| 10 |
|
| 11 |
// @codeCoverageIgnoreStart |
| 12 |
if ( ! defined( 'ABSPATH' ) ) { |
| 13 |
exit; // Exit if accessed directly. |
| 14 |
} |
| 15 |
|
| 16 |
/** |
| 17 |
* Displays the HTML generator tag for the plugin. |
| 18 |
* |
| 19 |
* See {@see 'wp_head'}. |
| 20 |
* |
| 21 |
* @since 1.0.1 |
| 22 |
*/ |
| 23 |
function auto_sizes_render_generator(): void { |
| 24 |
// Use the plugin slug as it is immutable. |
| 25 |
echo '<meta name="generator" content="auto-sizes ' . esc_attr( IMAGE_AUTO_SIZES_VERSION ) . '">' . "\n"; |
| 26 |
} |
| 27 |
add_action( 'wp_head', 'auto_sizes_render_generator' ); |
| 28 |
|
| 29 |
/** |
| 30 |
* Filters related to the improved image sizes functionality. |
| 31 |
*/ |
| 32 |
add_filter( 'the_content', 'auto_sizes_prime_attachment_caches', 9 ); // This must run before 'do_blocks', which runs at priority 9. |
| 33 |
add_filter( 'render_block_core/image', 'auto_sizes_filter_image_tag', 10, 3 ); |
| 34 |
add_filter( 'render_block_core/cover', 'auto_sizes_filter_image_tag', 10, 3 ); |
| 35 |
add_filter( 'render_block_core/post-featured-image', 'auto_sizes_filter_image_tag', 10, 3 ); |
| 36 |
add_filter( 'get_block_type_uses_context', 'auto_sizes_filter_uses_context', 10, 2 ); |
| 37 |
add_filter( 'render_block_context', 'auto_sizes_filter_render_block_context', 10, 3 ); |
| 38 |
// @codeCoverageIgnoreEnd |
| 39 |
|