Adding A Unique Image to a Course on Summary Page

Adding A Unique Image to a Course on Summary Page

by megan flaherty -
Number of replies: 2

Hi -

I'm using 1.9 (...I know, but the customer isn't upgrading yet). I'm trying to add an option to add a unique image to represent a course with the option to select rather than the instructor image on the summary page.

I've added 2 new course custom fields. I created a new field type of 'courseImage' based on the field 'file' type.  I am able to upload an image and check if I want it to be the default. That works fine. I can get the information out of the mdl_course_data_info and field tables.

The trouble is that I cannot resize the images on reload or verify image type with my approach. I'm trying to work it something like the user profile image process but can't seem to tie them together. I've been using PHP for almost a year but am lost here.

I'm trying not to overwrite core code if possible. Any suggestions?

 

Thanks.

Average of ratings: -
In reply to megan flaherty

Re: Adding A Unique Image to a Course on Summary Page

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Hi Megan,

If you want to look at image resizing code for M1.9, look at the Grid format: https://github.com/gjb2048/moodle-courseformat_grid/blob/MOODLE_19_STABLE/imagelib.php and https://github.com/gjb2048/moodle-courseformat_grid/blob/MOODLE_19_STABLE/editimage.php.  I did not write the code even through I now maintain the M2.x versions (2.5+ only) so would not be able to explain it off the top of my head.

Gareth

In reply to Gareth J Barnard

Re: Adding A Unique Image to a Course on Summary Page

by megan flaherty -

Hi Gareth,

I can take a look at that although the code is already in the user profile image upload using the lib/gdlib.php code. I just can't figure out exactly how to implement it. I've created the custom fields and I have a custom_lib page which displays the right image - just not the right size. 

I'll see if the code you suggest can give me an idea.

Thanks.