Display poster image for audio ads
Stay organized with collections
Save and categorize content based on your preferences.
This guide demonstrates how to use the IMA HTML5 SDK to overlay your video
player with a poster image when audio ads are played. This should be used when
ad_type=audio_video
is set in your VAST URL request. Doing this allows for
improved ad monetization as both audio and video ads are eligible and complete
to be served. See the ad_type
documentation
and Audio in video
content
for more details.
You can follow along with this guide, making the changes to a basic IMA
integrations, or see the
audio in video sample app
for a full integration with this feature.
Prerequisites
- An app implementing the IMA HTML5 SDK for video ads. See the IMA HTML5
getting started guide
for more information.
- A default poster image which overlays the video player when an audio ad is
served without a relevant overlay image. In order for the image to fit within
the video player, its width must be less than or equal to that of the video
player and its height must be at least 75 px less than that of the video
player.
Enable the poster image feature
Before making your audio and video ad request, set the audioPosterImageEnabled
feature flag to true
and the audioPosterImageDefaultUrl
feature flag to
your default poster image URL. Do this with the
ImaSdkSettings.setFeatureFlags()
API before creating the AdDisplayContainer
. When this is set and an audio ad
is playing, IMA automatically overlays an image related to the ad on top of the
video player. IMA chooses the largest companion ad image available that fits
within the video player and is at least 75 px shorter than the video player.
If the ad's VAST doesn't include an image that IMA can use as an overlay, IMA
uses your specified default image as an overlay.
function initializeIMA() {
console.log('initializing IMA');
adContainer = document.getElementById('ad-container');
google.ima.settings.setFeatureFlags(
{
'audioPosterImageEnabled': true,
'audioPosterImageDefaultUrl':'http://your-ad-overlay/image.png'
});
adDisplayContainer = new google.ima.AdDisplayContainer(adContainer, videoElement);
adsLoader = new google.ima.AdsLoader(adDisplayContainer);
// Let the AdsLoader know when the video has ended
videoElement.addEventListener('ended', function() {
adsLoader.contentComplete();
});
var adsRequest = new google.ima.AdsRequest();
adsRequest.adTagUrl = 'http://your-audio-video-ad-tag';
...
// Pass the request to the adsLoader to request ads
adsLoader.requestAds(adsRequest);
}
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-07-31 UTC.
[null,null,["Last updated 2025-07-31 UTC."],[[["\u003cp\u003eThis guide explains how to overlay a poster image on your video player during audio ads using the IMA HTML5 SDK to enhance ad monetization.\u003c/p\u003e\n"],["\u003cp\u003eThis implementation involves enabling the \u003ccode\u003eaudioPosterImageEnabled\u003c/code\u003e and \u003ccode\u003eaudioPosterImageDefaultUrl\u003c/code\u003e feature flags in the IMA SDK settings.\u003c/p\u003e\n"],["\u003cp\u003eDuring audio ad playback, IMA automatically selects and displays a relevant companion ad image or the default image as an overlay on the video player.\u003c/p\u003e\n"],["\u003cp\u003eTo use this feature, you need a basic IMA HTML5 SDK integration and a default poster image meeting specific size requirements.\u003c/p\u003e\n"],["\u003cp\u003eRefer to the provided links for detailed information on ad types, audio in video content, and a sample implementation.\u003c/p\u003e\n"]]],[],null,["# Display poster image for audio ads\n\nThis guide demonstrates how to use the IMA HTML5 SDK to overlay your video\nplayer with a poster image when audio ads are played. This should be used when\n`ad_type=audio_video` is set in your VAST URL request. Doing this allows for\nimproved ad monetization as both audio and video ads are eligible and complete\nto be served. See the [`ad_type`\ndocumentation](//support.google.com/admanager/answer/10678356#ad_type)\nand [Audio in video\ncontent](//support.google.com/admanager/answer/7642796#audio-in-video-content)\nfor more details.\n\nYou can follow along with this guide, making the changes to a basic IMA\nintegrations, or see the\n[audio in video sample app](//github.com/googleads/googleads-ima-html5/tree/main/audio_in_video)\nfor a full integration with this feature.\n\nPrerequisites\n-------------\n\n- An app implementing the IMA HTML5 SDK for video ads. See the [IMA HTML5\n getting started guide](/interactive-media-ads/docs/sdks/html5/client-side) for more information.\n- A default poster image which overlays the video player when an audio ad is served without a relevant overlay image. In order for the image to fit within the video player, its width must be less than or equal to that of the video player and its height must be at least 75 px less than that of the video player.\n\nEnable the poster image feature\n-------------------------------\n\nBefore making your audio and video ad request, set the `audioPosterImageEnabled`\nfeature flag to `true` and the `audioPosterImageDefaultUrl` feature flag to\nyour default poster image URL. Do this with the\n[`ImaSdkSettings.setFeatureFlags()`](/interactive-media-ads/docs/sdks/html5/client-side/reference/interface/google.ima.ImaSdkSettings#google.ima.ImaSdkSettings.setFeatureFlags)\nAPI before creating the `AdDisplayContainer`. When this is set and an audio ad\nis playing, IMA automatically overlays an image related to the ad on top of the\nvideo player. IMA chooses the largest companion ad image available that fits\nwithin the video player and is at least 75 px shorter than the video player.\nIf the ad's VAST doesn't include an image that IMA can use as an overlay, IMA\nuses your specified default image as an overlay. \n\n function initializeIMA() {\n console.log('initializing IMA');\n adContainer = document.getElementById('ad-container');\n google.ima.settings.setFeatureFlags(\n {\n 'audioPosterImageEnabled': true,\n 'audioPosterImageDefaultUrl':'http://your-ad-overlay/image.png'\n });\n adDisplayContainer = new google.ima.AdDisplayContainer(adContainer, videoElement);\n adsLoader = new google.ima.AdsLoader(adDisplayContainer);\n\n // Let the AdsLoader know when the video has ended\n videoElement.addEventListener('ended', function() {\n adsLoader.contentComplete();\n });\n\n var adsRequest = new google.ima.AdsRequest();\n adsRequest.adTagUrl = 'http://your-audio-video-ad-tag';\n ...\n // Pass the request to the adsLoader to request ads\n adsLoader.requestAds(adsRequest);\n }"]]