llms_get_certificate_image( int $id )

Retrieve an array of image data for a certificate background image


Description Description

If no image found, will default to the LifterLMS placeholder (which can be filtered for a custom placeholder).


Top ↑

Parameters Parameters

$id

(int) (Optional) WP Certificate Post ID. Default is 0. When not provide the current post id will be used.


Top ↑

Return Return

(array) Associative array of certificate image details


Top ↑

Source Source

File: includes/functions/llms.functions.certificate.php

function llms_get_certificate_image( $id = 0 ) {

	$id = ( $id ) ? $id : get_the_ID();

	$img_id = get_post_meta( $id, '_llms_certificate_image', true );

	// Don't retrieve a size if legacy mode is enabled.
	$size = ( 'yes' === get_option( 'lifterlms_certificate_legacy_image_size', 'yes' ) ) ? '' : 'lifterlms_certificate_background';

	$src = wp_get_attachment_image_src( $img_id, $size );

	if ( ! $src ) {

		$height = apply_filters( 'lifterlms_certificate_background_image_placeholder_height', 616, $id );
		$width  = apply_filters( 'lifterlms_certificate_background_image_placeholder_width', 800, $id );
		$src    = apply_filters( 'lifterlms_certificate_background_image_placeholder_src', LLMS()->plugin_url() . '/assets/images/optional_certificate.png', $id );

	} else {

		$height = apply_filters( 'lifterlms_certificate_background_image_height', $src[2], $id );
		$width  = apply_filters( 'lifterlms_certificate_background_image_width', $src[1], $id );
		$src    = apply_filters( 'lifterlms_certificate_background_image_src', $src[0], $id );

	}

	return array(
		'height' => $height,
		'src'    => $src,
		'width'  => $width,
	);

}


Top ↑

Changelog Changelog

Changelog
Version Description
2.2.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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