PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.9
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.9
4.4.9 4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 All 140 releases
← All changes | inc/class-lp-thumbnail-helper.php +14 -33 4.1.7.2 → 4.4.9 View file →
@@ -1,6 +1,8 @@
1 1 <?php
2 2
3 +use LearnPress\Models\CourseModel;
4 +
3 5 /**
4 6 * Class LP_Thumbnail_Helper
5 7 *
6 8 * @since 3.0.11
@@ -25,45 +27,24 @@
25 27 *
26 28 * @return string
27 29 */
28 30 public function get_course_image( $course_id, $size = 'course_thumbnail', $attr = array() ) {
29 - $course = learn_press_get_course( $course_id );
30 -
31 - if ( ! $course ) {
31 + $courseModel = CourseModel::find( $course_id, true );
32 + if ( ! $courseModel ) {
32 33 return '';
33 34 }
34 35
35 - $attr = wp_parse_args(
36 - $attr,
37 - array(
38 - 'alt' => $course->get_title(),
39 - 'title' => $course->get_title(),
40 - )
36 + $size_img_setting = LP_Settings::get_option( 'course_thumbnail_dimensions', [] );
37 + $size_img_send = [
38 + $size_img_setting['width'] ?? 500,
39 + $size_img_setting['height'] ?? 300,
40 + ];
41 + $image_url = $courseModel->get_image_url( $size_img_send );
42 + $image = sprintf(
43 + '<img src="%s" alt="%s">',
44 + esc_url_raw( $image_url ),
45 + $courseModel->get_title()
41 46 );
42 - $image = '';
43 -
44 - $thumbnail = learn_press_get_course_thumbnail_dimensions();
45 - $size = array( $thumbnail['width'], $thumbnail['height'] );
46 -
47 - $parent_id = wp_get_post_parent_id( $course_id );
48 -
49 - if ( has_post_thumbnail( $course_id ) ) {
50 - $image = get_the_post_thumbnail( $course_id, $size, $attr );
51 - } elseif ( $parent_id && has_post_thumbnail( $parent_id ) ) {
52 - $image = get_the_post_thumbnail( $parent_id, $size, $attr );
53 - }
54 -
55 - if ( ! $image ) {
56 - $image = LearnPress::instance()->image( 'no-image.png' );
57 - $image = sprintf(
58 - '<img src="%s" alt="%s">',
59 - esc_url_raw( $image ),
60 - _x( 'course thumbnail', 'no course thumbnail', 'learnpress' )
61 - );
62 - }
63 -
64 - // @deprecated
65 - // $image = apply_filters( 'learn_press_course_image', $image, $course_id, $size, $attr );
66 47
67 48 return $image;
68 49 }
69 50