Get the image an episode’s video shows before playback, for a theme or another add-on
benecaster_video_podcast_enhanced_get_episode_poster_url( $episode_id, $size ) answers, in order: the poster image chosen on the episode editor’s Video tab, at $size (any registered image size); else the episode’s artwork; else the show’s; else ''.
- On a show where Video Podcast Enhanced is switched off, the poster is ignored and the answer is the artwork, as Benecaster’s own video shows there. The poster is kept and counts again when the add-on is switched back on.
- It is defined whenever the add-on is active, even when it is off for every show. Check
function_exists()only if your code also runs without the add-on. - There is no access or status check: decide yourself whether the visitor may see the episode. The URL is raw: escape it with
esc_url().
To change the answer, filter benecaster_video_podcast_enhanced_episode_poster_url ( $url, $episode_id, $show_id, $size ). It runs only where the add-on is on for the episode’s show.
Code
<?php
// A theme's episode card: the video's poster, or the artwork, at card size.
$image = function_exists( 'benecaster_video_podcast_enhanced_get_episode_poster_url' )
? benecaster_video_podcast_enhanced_get_episode_poster_url( $episode_id, 'medium_large' )
: benecaster_get_episode_artwork( $episode_id );
if ( '' !== $image ) {
printf( '<img src="%s" alt="" loading="lazy">', esc_url( $image ) );
}
Hooks Used
Need this built rather than just documented? See our services →