if ( !
$has_filter ) { $filter_added =
add_filter( 'wp_get_attachment_image_context', '_filter_do_shortcode_context'
);
} $content =
do_shortcodes_in_html_tags( $content,
$ignore_html,
$tagnames );
$pattern =
get_shortcode_regex( $tagnames );
$content =
preg_replace_callback( "/
$pattern/", 'do_shortcode_tag',
$content );
// Always restore square braces so we don't break things like <!--[if IE ]>.
$content =
unescape_invalid_shortcodes( $content );
// Only remove the filter if it was added in this scope.
if ( $filter_added ) { remove_filter( 'wp_get_attachment_image_context', '_filter_do_shortcode_context'
);
} return $content;
}/**
* Filter the `wp_get_attachment_image_context` hook during shortcode rendering.
*
* When wp_get_attachment_image() is called during shortcode rendering, we need to make clear
* that the context is a shortcode and not part of the theme's template rendering logic.
*
* @since 6.3.0
* @access private
*
* @return string The filtered context value for wp_get_attachment_images when doing shortcodes.
*/