Changing the default user picture with a theme?

Changing the default user picture with a theme?

by Samuli Karevaara -
Number of replies: 19

Can the the default user picture be changed with a theme? The Docs say that it could ("The site administrator can change the default picture for the site by replacing the F1 and F2 images in the theme or pic folders") but I can't seem to be able to do that. Where should the f1.png and f2.png be inside the theme? I've tried /themename/pics/ and /themename/pics/u/ but alas no help.

The code seems to refer to the profile picture as coming from the component "core", so are the Docs deprecated in this regard, or am I missing something?

Average of ratings: -
In reply to Samuli Karevaara

Re: Changing the default user picture with a theme?

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

Re: Changing the default user picture with a theme?

by Samuli Karevaara -

Thanks, it was /theme/themename/pix_core/u/ that needs to hold the f1.png and f2.png. I searched for "default user picture" and didn't stumble upon the theme dev pages (d'oh), only at http://docs.moodle.org/26/en/User_pictures. I've updated that page based on what I learned.

Average of ratings: Useful (1)
In reply to Samuli Karevaara

Re: Changing the default user picture with a theme?

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

If you right click on the image and then copy image url to a fresh browser page, it will tell you where to look.  In mine, it is in my theme/core/long number/u.

In reply to Emma Richardson

Re: Changing the default user picture with a theme?

by Samuli Karevaara -

Thanks for the tip, though with version 2.6.2 I got /theme/image.php?theme=themename&component=core&image=u%2Ff1. This only gave the php script file image.php as a starting point for the search. I even went into the code to take a peek, but with so much magic in the code these days it's hard to follow where this blank user picture file location originates from in the code.gives 

In reply to Samuli Karevaara

Re: Changing the default user picture with a theme?

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Hi,

To make the User Picture change from Theme to theme you need to...

  1. Disable the use of  Gravatars : Settings > Site administration > Users > Permissions > User policies
  2. Add a pix_core directory to your theme. Inside that pix_core directory you add a sub-directory and name it 'u'. then in pix_core/u/ add f1.png and f2.png for that theme. 
    You can see this in Afterburner theme ... HERE

If you want to know more about using images in themes please ask.

Thanks

Mary

In reply to Mary Evans

Re: Changing the default user picture with a theme?

by William Michael -

Hello Mary,

Trying to follow your simple directions there, but the uploaded images, after I rename them "f1.png" and "f2.png", convert to the original images.   

I've never seen anything like that before.

William Michael

In reply to William Michael

Re: Changing the default user picture with a theme?

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Hi,

I am not sure what you mean...however I will take a stab in the dark and ask if you have done a Purge all cache for your site as this could be the cause of not seeing the changes you have made.

If you did purge all the caches then I will assume that the two images you up-loaded to your theme were another image format type like .gif or .jpg, so Moodle would not recognise them as .png and so would revert back to the default images in Moodle core pix directory. You cannot change the format of an image unless you use a graphic software like Photoshop or via an online service.

Let's hope it is one or the other of the above?

Cheers

Mary

In reply to Mary Evans

Re: Changing the default user picture with a theme?

by William Michael -

No, I'm working in FTP, uploading .png images as I always do to my theme's .../pix-core/u/ folder.  I work with image files all day long, so I'm not confused about file types, etc.  

Here's what happens:

1. I delete the default images-- f1.png, f2.png--and prepare to upload my own .png images.


2.  After uploading, the default images are restored and my uploaded images are not visible:


I have never experienced this before.

WM

In reply to William Michael

Re: Changing the default user picture with a theme?

by Richard Oelmann -
Picture of Core developers Picture of Plugin developers Picture of Testers

Hmmm - but that's in your ftp program before you get as far as trying it out in Moodle? :/

I'm not 100% sure as I don't tend to use ftp - I have ssh access onto the server itself, but that seems to me to be an issue with the ftp upload or possibly permissions on the folder?

In reply to Richard Oelmann

Re: Changing the default user picture with a theme?

by William Michael -

Thanks.  I'm not too comfortable with SSH...don't like the idea of giving commands "in the dark" if you know what I mean.  

I don't think it's a file permission issue, though, because I can upload images into the folder.  However, if I rename them "f1.png", etc., the default images are restored when I "save" the rename.  

WM

In reply to William Michael

Re: Changing the default user picture with a theme?

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

It's pix_core NOT pix-core

as in underscore NOT hyphen

In reply to Mary Evans

Re: Changing the default user picture with a theme?

by William Michael -

That was just a typo...the folder name is pix_core.

WM

In reply to Mary Evans

Re: Changing the default user picture with a theme?

by William Michael -

My theme designer just responded:

If you want to edit the default user picture, you have to change the images directly at your moodle installation:
Go to >> pathToYourMoodle/pix/u

Here you can replace the default images with your own custom ones.

Hope that helps,

WM


In reply to William Michael

Re: Changing the default user picture with a theme?

by Richard Oelmann -
Picture of Core developers Picture of Plugin developers Picture of Testers

No - that will alter the core ones and will get overridden on any upgrade. At least, yes you can do that BUT as I said, you will lose your changes any time you upgrade moodle.

Adding them to the theme/pix_core/u folder (or whatever appropriate sub-folder) is fine as the way Moodle works the theme images will override the core ones anyway. So I would advise sticking to the way you were doing it.

In reply to Richard Oelmann

Re: Changing the default user picture with a theme?

by William Michael -

Thank you, Richard.  I did both, actually, once I realize it was just an appearance, so I should be OK.

WM

In reply to William Michael

Re: Changing the default user picture with a theme?

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Ignore my last comment.

I was reading what you wrote...

"...my theme's .../pix-core/u/ folder..."

The images that you posted show the pix_core so that's correct.

My feeling is that it could be your computer cache that is storing the f1 & f2 images a little like what you get when changing a Moodle favicon.ico.

Try this...

  1. Close your FTP program.
  2. Delete your browser cache.
  3. Close browser and all tabs.
  4. Open new window in browser.
  5. Open FTP and check is showing correct images.

Mary

In reply to William Michael

Re: Changing the default user picture with a theme?

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

You need to refresh your server using the FTP "refresh" option as well!

In reply to Mary Evans

Re: Changing the default user picture with a theme?

by William Michael -

Yes, Mary, that was it.

I opened one of the images on the server side and, while it appeared as the old default image in FTP, when opened in the browser, it was the new image.

Thank you very much.  Hopefully this thread will help others.

Peace,
WM

In reply to William Michael

Re: Changing the default user picture with a theme?

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Hi,

So pleased you got this sorted out at last!

Cache be it Server side or Browser or just plain old Moodle cache...it's a pain and the cause of grief among Theme developers and Moodlers alike, especially when you are working on something important.

And yes I am sure this will help others too!

Cheers...Mary