LLMS_Engagement_Handler::get_image_id( string $type, int $template_id )

Retrieve the attachment id to use for the earned engagement thumbnail.

Description Description

Retrieves the template’s featured image ID and validates and then falls back to the site’s global default image option.

If no global option is found, returns 0. During front-end display, the hardcoded image will be used in the template if the earned engagement’s thumbnail is set to a fasly.

Top ↑

Parameters Parameters


(string) (Required) Type of engagement, either "achievement" or "certificate".


(int) (Required) WP_Post ID of the template post.

Top ↑

Return Return

(int) WP_Post ID of the attachment or 0 when none found.

Top ↑

Source Source

File: includes/class-llms-engagement-handler.php

	public static function get_image_id( $type, $template_id ) {

		$img_id = get_post_meta( $template_id, '_thumbnail_id', true );

		if ( $img_id && get_post( $img_id ) ) {
			return absint( $img_id );

		if ( 'achievement' === $type ) {
			return llms()->achievements()->get_default_image_id();

		if ( 'certificate' === $type ) {
			return llms()->certificates()->get_default_image_id();

		return 0;


Top ↑

Changelog Changelog

Version Description
6.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.