LLMS_User_Achievement::get_image( int[] $size = array(), null $unused = null )
Retrieve the image source for the achievement.
Parameters Parameters
- $size
-
(int[]) (Optional) Dimensions of the image to return passed as [ width, height ] (in pixels).
Default value: array()
- $unused
-
(null) (Optional) Unused parameter inherited from the parent method.
Default value: null
Return Return
(string) Image source URL.
Source Source
File: includes/models/model.llms.user.achievement.php
public function get_image( $size = array(), $unused = null ) {
$id = $this->get( 'id' );
$img_id = get_post_thumbnail_id( $id );
$size = empty( $size ) ? array( 380, 380 ) : $size;
/**
* Filters the size used to retrieve an achievement image.
*
* @since 6.0.0
*
* @param int[] $size Dimensions of the image passed as [ width, height ] (in pixels).
*/
$size = apply_filters( 'llms_achievement_image_size', $size );
if ( ! $img_id ) {
$src = llms()->achievements()->get_default_image( $id );
} else {
list( $src ) = wp_get_attachment_image_src( $img_id, $size );
}
/**
* Filter the image source URL for the achievement.
*
* @since 6.0.0
*
* @param string $src Image source URL.
* @param LLMS_User_Achievement $achievement The achievement object.
* @param int[] $size Dimensions of the image to return passed as [ width, height ] (in pixels).
*/
return apply_filters( 'llms_achievement_get_image', $src, $this, $size );
}
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 6.0.0 | Set a default size when an empty array is passed and use global default image when possible. |
| 3.14.0 | Introduced. |