Adding html banner to posts

I’m writing a plugin that adds a banner to the top of all blog posts. I’m using the_content filter and just pre-pending some html to it. When doing this, the html isn’t shown in the excerpt, but I want the banner to be there. What do I need to do? I don’t want to allow any additional html tags that users can put in the excerpt.

Edit:

I’m now using a combination of the_content and the excerpt filters to display the banner. I don’t want to just add the banner to the content, it displays on the content page, but not the post list page. Using just the_excerpt will only display on the post list page (depending on the theme) and not the individual post page. I’ve been using the is_single function to help distinguish between the post list page and the page for a single post. Here is what my code looks like so far.

function display_banner( $content ) {
    return '<div class="banner">Banner</div>' . $content;
}

function display_content_banner() {
    if ( is_single() ) {
        return display_banner( $content );
    } else {
        return $content; //on the post list page, the_excerpt is in charge of displaying the banner.
    }
}
add_filter('the_excerpt', 'display_banner');
add_filter('the_content', 'display_content_banner');

The problem I’m getting is that some themes don’t display the excerpt on the post list page, they display to full post text, so my banner is not getting placed when this occurs.

Solutions Collecting From Web of "Adding html banner to posts"

rss_use_excerpt is the option people can use to change the blog from Full Text to Summary. With a combination of is_front_page and that setting you can determine if you’re blog page is showing the summary — in your case — when you don’t want to show the banner on the blog page.

function display_banner($content)
{
    return '<div class="banner">Banner</div>' . $content;
}

function display_content_banner($content)
{
    // [ 0:NO, 1:YES ] - https://codex.wordpress.org/Option_Reference#Reading
    static $rss_use_excerpt;
    if( ! isset($rss_use_excerpt)) $rss_use_excerpt = get_option('rss_use_excerpt');

    if(is_single() || (is_front_page() && ! $rss_use_excerpt)) {
        return display_banner($content);
    }
    else {
        return $content; //on the post list page, the_excerpt is in charge of displaying the banner.
    }
}

add_filter('the_excerpt', 'display_banner');
add_filter('the_content', 'display_content_banner');