Tweaks to Clean Theme

Tweaks to Clean Theme

by Jeff Ferrell -
Number of replies: 9

I'm modifying a copy of the Clean Theme in Moodle 2.7, and I'm trying to enlarge the user pictures in the headings of Forum posts. I'm seeing this in the code:  

<img src="http://ferrellweb.com/moodle/pluginfile.php/5/user/icon/fweb3/f2?rev=63" alt="Picture of Mr. Ferrell" title="Picture of Mr. Ferrell" class="userpicture" width="35" height="35">

So I'm assuming that the width and height are set programmatically somewhere--I can't tinker with them through a stylesheet.


I'm pretty handy mucking around in code, but a newbie when it comes to Moodle Themes, and Moodle itself, really. Is there a setting somewhere that specifies a "standard" avatar size? Or do I need to actually modify a core file somewhere? If the latter, can I move/copy the relevant files into my theme somewhere?

Thanks!

Average of ratings: -
In reply to Jeff Ferrell

Re: Tweaks to Clean Theme

by Mary Evans -

The size of the user avatar is made that size by default for a reason and this is more to do with its location in the table cell it sits in. You could try changing the size using CSS ...

#page-mod-forum img.user picture { height: 60px !important ;width: 60px !important;}

or whatever width/height you prefer.

In reply to Mary Evans

Re: Tweaks to Clean Theme

by Jeff Ferrell -

Thanks, Mary, but it seems the images is being resized already by some engine to match the 35px specified in the HTML. Here's what happens when I resize the image using pure CSS:

resized forum avatar

So what I'm seeing, then, is a 35px image, stretched to 90px by the CSS. mixed (The original avatar size is 128x128px -- and yeah, I'm stealing the appearance of this forum a little bit, I guess--just so happens that orange works well for me, too. tongueout)

In reply to Jeff Ferrell

Re: Tweaks to Clean Theme

by Jeff Ferrell -

Wait, wait--it looks like the image called here

. . . pluginfile.php/5/user/icon/fweb3/f2?rev=63

is actually 35px by 35px. But I'm not sure how that's being generated from the original 128px size, or why it's called that way in the forum in particular? Does Moodle pre-generate different avatar sizes?

In reply to Jeff Ferrell

Re: Tweaks to Clean Theme

by Jeff Ferrell -

Gah! Sorry for all the re-re-replies. I probably shouldn't be thinking out loud on a message board. I think I'm beginning to see, though:

http://ferrellweb.com/moodle/pluginfile.php/5/user/icon/fweb3/f2?rev=2392

gives me a 35x35 image.

http://ferrellweb.com/moodle/pluginfile.php/5/user/icon/fweb3/f1?rev=2392

gives me a 100x100 image to work with. Can anyone explain how that works? Since the forum module evidently calls the "f2" version of the avatar, do I need to change that in the module code somewhere? Or could I modify that for just my theme?



In reply to Jeff Ferrell

Re: Tweaks to Clean Theme

by Mary Evans -

You could try overriding the mod/forum/renderer.php 

http://docs.moodle.org/dev/Overriding_a_renderer

If you look at the mod/forum/renderer.php you will find a function that adds the user image and by following the examples in the tutorial I have linked to you should be able to change the size of the image.

sorry I can't help further as I'm away from my computer and it's not as easy working on an iPad! Lol

In reply to Mary Evans

Re: Tweaks to Clean Theme

by Mary Evans -

Further to my last comment here is the core renderer which may help you understand how to change the way moodle looks...

https://github.com/moodle/moodle/blob/master/lib/outputrenderers.php

In reply to Mary Evans

Re: Tweaks to Clean Theme

by Jeff Ferrell -

Ok, I feel like I'm chasing my own tail here, so I'll pause for a breather. Here's what I'm looking at:


So the code that (more or less) sets the size of the user picture is in outputrenderers.php, right? (line 2280 or so)

 if (empty($userpicture->size)) {
            $size = 35;
        } else if ($userpicture->size === true or $userpicture->size == 1) {
            $size = 100;
        } else {
            $size = $userpicture->size;
        }

But I don't want to mess with that to tweak forum avatar sizes, because that's just a general switch that flips based on the 'size' parameter fed from some other function call.


All I can find in mod/forum/renderer.php that has to do with user pictures is a function subscriber_overview that has this comment: This function generates HTML to display a subscriber overview, primarily used on the subscribers page if editing was turned off.

So that's not what I want. There doesn't seem to be anything there having to do with user pictures in general, so I went looking elsewhere.


In /mod/forum/view.php, there is a function forum_print_latest_discussions that seems to be invoked when we're finally getting down to business. That traces back to /mod/forum/lib.php, where there's this bit:

// Picture
    $postuser = new stdClass();
    $postuserfields = explode(',', user_picture::fields());
    $postuser = username_load_fields_from_object($postuser, $post, null, $postuserfields);
    $postuser->id = $post->userid;
    echo '<td class="picture">';
    echo $OUTPUT->user_picture($postuser, array('courseid'=>$forum->course));
    echo "</td>\n";

Which seems to be where I'd want to feed an extra 'size == 1' parameter to make outputrenderers.php kick out a large-sized user pic. Except that snippet is outputting table/cell code that doesn't exist in the actual rendered web page.

The Clean theme is on BootstrapBase, right, but I haven't found anything helpful in renderers there, either.

So I think I'm pretty well lost (I'm not even sure I'd be able to explain this stuff again, if I needed to!) -- am I headed way off the rails?

In reply to Jeff Ferrell

Re: Tweaks to Clean Theme

by Jeff Ferrell -

*Sigh* Finished up the school year, and thought I'd take another crack at this, but I'm still barking up the wrong codetree.

In the second code block from teh post above, I've manually added 'size' => 1 (and also tried 'size' => 70) to the user_picture function array, with no luck. (I expected this, because the HTML doesn't line up with the structure on my forum page.)

What's more frustrating, I think, is that (just to try to make something happen) I changed the line in outputrenderers.php from $size = 35 to $size = 100, with no discernable results. 

I just can't seem to track down where the forum mod is pulling its display code from, really. Spent some time this evening sifting through all the Moodle code, searching for various strings that I thought might be useful, but no luck--nothing seems appropriate. 

It seems like this should be pretty straightforward, so I can't help but feel that I'm overlooking something totally obvious. Anyone know where this code is hiding?

In reply to Jeff Ferrell

Re: Tweaks to Clean Theme

by Robert Brenstein -
When you upload a pic for avatar, Moodle automatically converts it into two images, one 100x100 and another 35x35, as you discovered. The original pic is not kept.