epl_elementor_agent_image: the agent photo in the Elementor widgets

Description #

Filters the agent photo HTML in the Elementor Author Box and Photo widgets.

EPL starts with the agent's Gravatar (get_avatar()) at the requested size. When the agent is a Staff Directory post and Staff Directory is set to use featured images, it uses the post's featured image, or Staff Directory's fallback image. It then applies EPL's existing epl_author_tab_image filter, then this one. The result is printed through wp_kses_post().

Part of the Elementor integration, which is in beta. See Elementor widgets and templates (beta) for how the widgets and templates fit together.


Usage #

add_filter( 'epl_elementor_agent_image', 'my_function', 10, 3 );

Parameters #

$image_html (string)
The image HTML.

$agent (EPL_Author_Loader)
The agent. $agent->author_id is the user (or Directory post) ID.

$size (int)
The size the widget asked for, in pixels (at least 1).


Examples #

Use an image saved in the agent's my_agent_photo_id user meta:

function my_epl_agent_photo( $image_html, $agent, $size ) {
	$attachment_id = (int) get_user_meta( $agent->author_id, 'my_agent_photo_id', true );
	if ( $attachment_id ) {
		return wp_get_attachment_image( $attachment_id, array( $size, $size ) );
	}
	return $image_html;
}
add_filter( 'epl_elementor_agent_image', 'my_epl_agent_photo', 10, 3 );

Source #

lib/page-builders/elementor/class-epl-elementor.php, in EPL_Elementor::get_agent_image(). Since 3.6.