epl_author_tab_image: change the agent's photo

Description #

Changes the agent photo in the author box, the author archive card and the tall author widget. By default it is the agent's Gravatar at 150 pixels. Since 3.6 the Elementor Agent Box and Agent Photo widgets use it too.

The Staff Directory add-on uses this filter to show the staff member's photo instead of the Gravatar.


Usage #

add_filter( 'epl_author_tab_image', 'my_author_tab_image', 20, 2 );

Parameters #

$image_html (string)
The photo's <img> HTML. Default get_avatar( $epl_author->email, 150 ). In the Elementor widgets it is already the Staff Directory photo when there is one, at the widget's size.

$epl_author (object)
The agent (EPL_Author_Meta), with author_id, email and the other agent details.


Examples #

Use a photo saved in the agent's user profile as an attachment ID, and keep the Gravatar for agents without one.

function my_author_tab_image( $image_html, $epl_author ) {
	$photo_id = (int) get_user_meta( $epl_author->author_id, 'my_agent_photo_id', true );

	if ( $photo_id ) {
		return wp_get_attachment_image( $photo_id, 'thumbnail' );
	}
	return $image_html;
}
add_filter( 'epl_author_tab_image', 'my_author_tab_image', 20, 2 );

Notes #

  • The author box prints the photo through wp_kses_post(), so stick to normal image HTML.
  • Elementor widgets then run epl_elementor_agent_image (the image, the agent and the size in pixels) for Elementor-only changes.
  • epl_author_tab_image() is also the function EPL adds to the epl_author_thumbnail action that the author templates run.


Source #

lib/includes/template-functions.php, in epl_author_tab_image() (since 2.0), and lib/page-builders/elementor/class-epl-elementor.php, in EPL_Elementor::get_agent_image() (since 3.6).