I wanted to make all course images to be same but I can't do it one by one uploading every single course image cuz there is thousands of courses so I was wondering if I tweak db I can change all course images pointing to same image on filedir is it possible ?
It doesn't need to be and (without checking) I don't think it is. The files table gives enough information to identify the course image for a given course.
Hey thanks for the reply, I noticed the files table but even I modify the table it doesn't work cuz url of files has the uid of record like
/pluginfile.php/8065/course/overviewfiles/courseimage.png
/pluginfile.php/8066/course/overviewfiles/courseimage.png
So it won't work but I come up with a trick to show the same image for all my courses
/pluginfile.php/8065/course/overviewfiles/courseimage.png
/pluginfile.php/8066/course/overviewfiles/courseimage.png
So it won't work but I come up with a trick to show the same image for all my courses
Hi Нурбек,
Would you mind sharing your trick to show the same image for all courses? We're planning on doing the same.
Regards
Jerry
Would you mind sharing your trick to show the same image for all courses? We're planning on doing the same.
Regards
Jerry
Sure,
I did it via CSS.
First you have to upload your course image to one of your courses then inspect your course and grab the URL of image.
After that you have to locate where do you want your course images to be the same like in courses overview or in site home etc... once you locate that inspect and get the CSS classes of where images are appears.
Lastly depending on your theme you have to inject CSS to your theme's setting usually in advanced settings.
Example CSS i put in my moodle:
.card-img-top.myoverviewimg.courseimage,
.card-img.dashboard-card-img,
.image_holder {
background-image: url(yourmoodle.com/pluginfile.php/8065/course/overviewfiles/cover.png) !important;
background-size: cover;
background-position-y: center;
}
I did it via CSS.
First you have to upload your course image to one of your courses then inspect your course and grab the URL of image.
After that you have to locate where do you want your course images to be the same like in courses overview or in site home etc... once you locate that inspect and get the CSS classes of where images are appears.
Lastly depending on your theme you have to inject CSS to your theme's setting usually in advanced settings.
Example CSS i put in my moodle:
.card-img-top.myoverviewimg.courseimage,
.card-img.dashboard-card-img,
.image_holder {
background-image: url(yourmoodle.com/pluginfile.php/8065/course/overviewfiles/cover.png) !important;
background-size: cover;
background-position-y: center;
}
Thanks Нурбек,
Turns out our requirement is slightly different, we want the course image to be a same image if the course doesn't already have one. This is what I ended up doing in the "course/classes/external/course_summary_exporter.php"
protected function get_other_values(renderer_base $output) {
global $CFG;
$courseimage = self::get_course_image($this->data);
if (!$courseimage) {
//$courseimage = $output->get_generated_image_for_id($this->data->id);
$courseimage = "yourmoodle.com/pluginfile.php/1580170/course/overviewfiles/223x112.png";
}
Turns out our requirement is slightly different, we want the course image to be a same image if the course doesn't already have one. This is what I ended up doing in the "course/classes/external/course_summary_exporter.php"
protected function get_other_values(renderer_base $output) {
global $CFG;
$courseimage = self::get_course_image($this->data);
if (!$courseimage) {
//$courseimage = $output->get_generated_image_for_id($this->data->id);
$courseimage = "yourmoodle.com/pluginfile.php/1580170/course/overviewfiles/223x112.png";
}
There's a way to duplicate course images using a database insert in this reply. It doesn't have any handling for courses that already have an image.
That will only work if the course that file is on can be accessed by everyone, otherwise permissions will prevent some people from seeing it. If you upload the file to the pix folder in your theme and access that directly (i.e. not using the pluginfile.php path - /theme/mytheme/pix/cover.png) that would be accessible by everyone.
These images are cached, so they only get refreshed properly when going through a form update (i.e. saving course settings) or using the file API to update the file. Updating the DB alone won't work as you intend.
These images are cached, so they only get refreshed properly when going through a form update (i.e. saving course settings) or using the file API to update the file. Updating the DB alone won't work as you intend.
Thanks Mark,
I noticed that after post 😅, it was on the plan to upload the image to the pix folder instead using pluginfile.php