Search
 
SCRIPT & CODE EXAMPLE
 

PHP

moodle get course image

// Create a course_in_list object to use the get_course_overviewfiles() method.
require_once($CFG->libdir . '/coursecatlib.php');
$course = new course_in_list($course); //don't send the id jsut send the whole course if not you will get the stcClass Error

$outputimage = '';
foreach ($course->get_course_overviewfiles() as $file) {
    if ($file->is_valid_image()) {
        $imagepath = '/' . $file->get_contextid() .
                '/' . $file->get_component() .
                '/' . $file->get_filearea() .
                $file->get_filepath() .
                $file->get_filename();
        $imageurl = file_encode_url($CFG->wwwroot . '/pluginfile.php', $imagepath,
                false);
        $outputimage = html_writer::tag('div',
                html_writer::empty_tag('img', array('src' => $imageurl)),
                array('class' => 'courseimage'));
        // Use the first image found.
        break;
    }
}
echo $outputimage;
Comment

PREVIOUS NEXT
Code Example
Php :: laravel override factory values in database seeder 
Php :: php count occurrences of string in array 
Php :: Proc file for laravel 
Php :: wordpress move debug.log 
Php :: yesterday php 
Php :: php var_dump more readable 
Php :: laravel where equal 
Php :: root composer.json requires php ^7.3 but your php version (8.0.3) does not satisfy that requirement. 
Php :: php call class method dynamically 
Php :: install phpmyadmin on vagrant homestead on mac 
Php :: laravel unique validation on multiple columns 
Php :: laravel get age from date 
Php :: laravel get id from insert 
Php :: wp image size name 
Php :: find days with name between two dates in php 
Php :: phpmyadmin 403 forbidden centos 6 
Php :: how to get data from json array in php 
Php :: laravel collection max 
Php :: default language laravel 
Php :: laravel collection get unique values 
Php :: php reverse dns lookup 
Php :: null value in php 
Php :: php datetime from timestamp 
Php :: destroy multiple sessions in laravel 
Php :: json stringify to php array 
Php :: get all sort by laravel 
Php :: laravel local scope 
Php :: how to make a loop that adds numbers to a variable in php 
Php :: return view inside subfolder laravel 
Php :: read xml file in php wordpress 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =