OK, first of all, I've been working on this in flexibase, which has 'includes' for component parts like header.php that the layout files can call. I've done this then as another include - it may (possibly) be better done as a part of lib.php, but it works this way - depending on how you are building your theme you may just take the code and put it directly in your layout file(s) as required. I am happy splitting the components into separate files as I find it easier to use for maintenance purposes. There may also be ways of converting this to a mustache template, but to be honest I haven't got very far looking at those as I find them just another thing to get in the way right now - maybe when I get chance to investigate them fully I'll find some benefit, right now they just seem another obstruction for new developers.
Attached is a courseimage.php file - this pulls out a file from the course summary file, checks that it is a valid image and if it is, generates the url that the image can be found at as a variable. If default settings have been altered to allow non-image files to be added as course summary files, then it ignores non-image files. If default settings have been altered to allow more than one file, then it uses the last in the list (alphabetically). The code could quite easily be changed to take the first in the list (check if the variable already has a value set and if it does don't change it. I'm not sure how (or if) it could be made to select a specific file from multiple images other than first/last.
In my theme to test this I have then included the courseimage.php file in the header.php (which is in turn included in the layout files)
* Theme Flexibase layout file.
* @package theme_flexibase
* @author 2015 Richard Oelmann
* @copyright 2015 R. Oelmann
* @copyright Bootstrap - 2014 Bas Brands
* Essential - Julian Ridden, Gareth Barnard;
* Elegance - Julian Ridden, Danny Wahl;
* BCU - Jez H, Mike Grant
* Decaf - Paul Nichols
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */
global $PAGE, $USER;
$pageid = $PAGE->bodyid;
$showlogo = (empty($PAGE->theme->settings->showlogo)) ? 'everywhere' : $PAGE->theme->settings->showlogo;
<nav role="navigation" class='navbar navbar-<?php echo $topbarcolour; ?> navbarbranding'>
and then added the image as an inline style background image to the moodleheader class I use for the header
<header class="moodleheader" style="background-image: url('<?php echo $courseimage;?>')">
I've also added some css to style the image (at the moment that is in customcss setting, but if I do add this feature to a future release then obviously it would go within a proper stylesheet.)
If I am adding this to a future version, then I would possibly also add a theme setting to allow a site wide default image - which may then require ensuring that the code was only in place for course pages and not in a general layout file as this currently is (if there is no course summary file it just returns empty, so it works fine on admin pages, front page etc by just not displaying anything). You could also have settings that would affect the way images are displayed - to set a site wide size, margins (so a 600x150 image is always centred for example) etc.
There's some other tidying up to do in terms of a full implementation - such as whether the image (if there is one) replaces the course header title, so that the header area doesn't become overly cluttered, but that is probably also a setting choice depending on how the course image is being used - is it a banner graphic that includes the course name, or a simple background image etc etc.
For now, the code works, it takes the course summary file image if there is one and puts it into the background of the header area. So Chris - the rest is up to you as to how you specifically want to implement that within your theme
Good luck - look forward to seeing your theme with your developments of this and how you use it
PS - quick note to anyone looking for it: you wont find this in my github for the theme yet as I am still working on how I want to implement it for future versions of flexibase, but it will get there soon ;)