diff --git a/public/plugin/BuyCourses/src/buy_course_plugin.class.php b/public/plugin/BuyCourses/src/buy_course_plugin.class.php index 7eb3bdc9ad4..1c38abc844e 100644 --- a/public/plugin/BuyCourses/src/buy_course_plugin.class.php +++ b/public/plugin/BuyCourses/src/buy_course_plugin.class.php @@ -805,22 +805,17 @@ public function getCourseInfo($courseId) 'course_img' => null, ]; - $courseTeachers = $course->getTeachersSubscriptions(); - - foreach ($courseTeachers as $teachers) { - /* @var User $user */ + foreach ($course->getTeachersSubscriptions() as $teachers) { $user = $teachers->getUser(); - $teacher['id'] = $user->getId(); - $teacher['name'] = $user->getFullName(); - $courseInfo['teachers'][] = $teacher; + $courseInfo['teachers'][] = [ + 'id' => $user->getId(), + 'name' => $user->getFullName(), + ]; } - $possiblePath = api_get_path(SYS_COURSE_PATH); - $possiblePath .= $course->getDirectory(); - $possiblePath .= '/course-pic.png'; - - if (file_exists($possiblePath)) { - $courseInfo['course_img'] = api_get_path(WEB_COURSE_PATH).$course->getDirectory().'/course-pic.png'; + $imgUrl = $this->getCourseIllustrationUrl($course); + if (!empty($imgUrl)) { + $courseInfo['course_img'] = $imgUrl; } return $courseInfo;