wp_content_img_tag
Filters an img tag within the content for a given context.
Usage
add_filter( 'wp_content_img_tag', 'wp_kama_content_img_tag_filter', 10, 3 ); /** * Function for `wp_content_img_tag` filter-hook. * * @param string $filtered_image Full img tag with attributes that will replace the source img tag. * @param string $context Additional context, like the current filter name or the function name from where this was called. * @param int $attachment_id The image attachment ID. May be 0 in case the image is not an attachment. * * @return string */ function wp_kama_content_img_tag_filter( $filtered_image, $context, $attachment_id ){ // filter... return $filtered_image; }
- $filtered_image(string)
- Full img tag with attributes that will replace the source img tag.
- $context(string)
- Additional context, like the current filter name or the function name from where this was called.
- $attachment_id(int)
- The image attachment ID. May be 0 in case the image is not an attachment.
Changelog
Since 6.0.0 | Introduced. |
Where the hook is called
wp_content_img_tag
wp-includes/media.php 1929
$filtered_image = apply_filters( 'wp_content_img_tag', $filtered_image, $context, $attachment_id );