LLMS_User_Certificate::get_background_image()

Retrieve information about the certificate background image.


Description Description

This function returns an array of information used for legacy certificates using the v1 template.

When using the v2 template, only the $src value is utilized and the background image itself is always set to 100% width and height of certificate as defined by the certificate’s sizing settings.


Top ↑

Return Return

(array) Returns an associative array of information about the background image.

  • 'src'
    (string) The image source url.
  • 'width'
    (int) The image display width, in pixels.
  • 'height'
    (int) The image display height, in pixels.
  • 'is_default'
    (bool) Whether or not the default image was returned.


Top ↑

Source Source

File: includes/models/model.llms.user.certificate.php

213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
public function get_background_image() {
 
    $id     = $this->get( 'id' );
    $img_id = get_post_thumbnail_id( $id );
 
    $size = 'full';
    if ( 1 === $this->get_template_version() ) {
        $size = llms_parse_bool( get_option( 'lifterlms_certificate_legacy_image_size', 'yes' ) ) ? 'full' : 'lifterlms_certificate_background';
    }
 
    if ( ! $img_id ) {
 
        // Get the source.
        $src = llms()->certificates()->get_default_image( $id );
 
        // Denote it's the default image in the return.
        $is_default = true;
 
        /**
         * Filters the display height of the default certificate background image.
         *
         * This filter is used by legacy certificates only. If the certificate is utilizing
         * the block editor the filtered value does not affect the size of the background image as
         * the image is always set to fill the width and height of the certificate itself.
         *
         * @since 2.2.0
         *
         * @param int $height         Display height of the image, in pixels.
         * @param int $certificate_id WP_Post ID of the awarded certificate.
         */
        $height = apply_filters( 'lifterlms_certificate_background_image_placeholder_height', 616, $id );
 
        /**
         * Filters the display width of the default certificate background image.
         *
         * This filter is used by legacy certificates only. If the certificate is utilizing
         * the block editor the filtered value does not affect the size of the background image as
         * the image is always set to fill the width and height of the certificate itself.
         *
         * @since 2.2.0
         *
         * @param int $width          Display width of the image, in pixels.
         * @param int $certificate_id WP_Post ID of the awarded certificate.
         */
        $width = apply_filters( 'lifterlms_certificate_background_image_placeholder_width', 800, $id );
 
    } else {
 
        list( $src, $width, $height ) = wp_get_attachment_image_src( $img_id, $size );
 
        // Denote it's not the default image in the return.
        $is_default = false;
 
        /**
         * Filters the image source of the certificate background image.
         *
         * @since 2.2.0
         *
         * @param string $src            The image source url.
         * @param int    $certificate_id WP_Post ID of the awarded certificate.
         */
        $src = apply_filters( 'lifterlms_certificate_background_image_src', $src, $id );
 
        /**
         * Filters the display height of the certificate background image.
         *
         * This filter is used by legacy certificates only. If the certificate is utilizing
         * the block editor the filtered value does not affect the size of the background image as
         * the image is always set to fill the width and height of the certificate itself.
         *
         * @since 2.2.0
         *
         * @param int $height         Display height of the image, in pixels.
         * @param int $certificate_id WP_Post ID of the awarded certificate.
         */
        $height = apply_filters( 'lifterlms_certificate_background_image_height', $height, $id );
 
        /**
         * Filters the display width of the certificate background image.
         *
         * This filter is used by legacy certificates only. If the certificate is utilizing
         * the block editor the filtered value does not affect the size of the background image as
         * the image is always set to fill the width and height of the certificate itself.
         *
         * @since 2.2.0
         *
         * @param int $width          Display width of the image, in pixels.
         * @param int $certificate_id WP_Post ID of the awarded certificate.
         */
        $width = apply_filters( 'lifterlms_certificate_background_image_width', $width, $id );
 
    }
 
    return compact( 'src', 'width', 'height', 'is_default' );
 
}


Top ↑

Changelog 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.