public static function get_course_image($course) {
        global $CFG;
        $courseinlist = new \core_course_list_element($course);
        foreach ($courseinlist->get_course_overviewfiles() as $file) {
            if ($file->is_valid_image()) {
                $pathcomponents = [
                    '/pluginfile.php',
                    $file->get_contextid(),
                    $file->get_component(),
                    $file->get_filearea() . $file->get_filepath() . $file->get_filename()
                ];
                $path = implode('/', $pathcomponents);
                return (new moodle_url($path))->out();
            }
        }
        return false;
    }
public static function get_course_image($course) {
        global $CFG;
        $courseinlist = new \core_course_list_element($course);
        foreach ($courseinlist->get_course_overviewfiles() as $file) {
            if ($file->is_valid_image()) {
                $pathcomponents = [
                    '/pluginfile.php',
                    $file->get_contextid(),
                    $file->get_component(),
                    $file->get_filearea() . $file->get_filepath() . $file->get_filename()
                ];
                $path = implode('/', $pathcomponents);
                return (new moodle_url($path))->out();
            }
        }
        return false;
    }
public static function get_course_image ( $ course ) { global $ CFG ; $ courseinlist = new \ core_course_list_element ( $ course ) ; foreach ( $ courseinlist -> get_course_overviewfiles ( ) as $ file ) { if ( $ file -> is_valid_image ( ) ) { $ pathcomponents = [ '/pluginfile.php' , $ file -> get_contextid ( ) , $ file -> get_component ( ) , $ file -> get_filearea ( ) . $ file -> get_filepath ( ) . $ file -> get_filename ( ) ] ; $ path = implode ( '/' , $ pathcomponents ) ; return ( new moodle_url ( $ path ) ) -> out ( ) ; } } return false ; }
Get the course image if added to course.

@param object $course
@return string url of course image
Get the course image if added to course .