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.
Parameters Parameters
- $type
-
(string) (Required) Type of engagement, either "achievement" or "certificate".
- $template_id
-
(int) (Required) WP_Post ID of the template post.
Return Return
(int) WP_Post ID of the attachment or 0
when none found.
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; }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
6.0.0 | Introduced. |