Skip to main content

benecaster_player_card_image_args

Filter Premium email-editor

Filters how an episode’s player card is drawn: the image {{player_image}} shows in an episode notification, the episode’s artwork with a darkening layer and a round play button. It runs whenever a card’s address is written into an email and whenever the card is drawn. A card is drawn once per set of arguments and kept in uploads/benecaster-email-editor/player-cards/, and the address in the email carries ?v= and a hash of all five arguments, the artwork address included. So a change here, or new artwork, draws a new card for new emails, and the episode’s older cards are deleted when it is drawn.

Parameters

Name Type Default Description
$args array — `artwork_url` (string, default the episode's artwork, falling back to the show's), `play_button_color` (`#rgb` or `#rrggbb`, default `#ffffff`; anything else draws white), `overlay_opacity` (float 0–1, default 0.4), `width` (int px, 100–1200, default 600), `height` (int px, 50–1200, default 200). Values outside a range are clamped to it.
$episode_id int — ID of the episode

Returns: array

Example

add_filter( 'benecaster_player_card_image_args', function ( array $args, int $episode_id ): array {
    if ( 12 === (int) wp_get_post_parent_id( $episode_id ) ) {
        $args['play_button_color'] = '#ffcc00';
        $args['overlay_opacity']   = 0.25;
    }
    return $args;
}, 10, 2 );

Notes

Return the same arguments for the same episode every time, or each request draws (and deletes) a card again. The card is served at GET /wp-json/benecaster/v1/episode/{id}/player-card.png, a public redirect to the file, only for a published episode with artwork, and it keeps serving when the Email Editor is off for the show so delivered mail keeps its image. Drawing needs PHP's GD extension; without it {{player_image}} is empty. Walkthrough: Use a custom brand color for the play button on one show's player cards.

Need this built rather than just documented? See our services →