Get user picture in CSS

Get user picture in CSS

ដោយ Richard van Iwaarden នៅ
ចំនួនតប៖ 5
រូបភាព Particularly helpful Moodlers

Is there any way to get the user-picture with CSS?

    background-image: url(http://moodle.org/pluginfile.php/7284/user/icon/theme/f1);


How can I make it so that i get the picture of the current logged in user with CSS?

Or is there another way? (note: I can not change PHP files as we have a hosted Moodle)

មធ្យមភាគនៃរង្វាយតម្លៃ: -
ឆ្លើយតបទៅកាន់ Richard van Iwaarden

Re: Get user picture in CSS

ដោយ Mary Evans នៅ
រូបភាព Core developers រូបភាព Documentation writers រូបភាព Peer reviewers រូបភាព Plugin developers រូបភាព Testers

If you tell me the name of the theme you are using and the version of Moodle, I may be able to advise you what to do.

មធ្យមភាគនៃរង្វាយតម្លៃ: -
ឆ្លើយតបទៅកាន់ Mary Evans

Re: Get user picture in CSS

ដោយ Richard van Iwaarden នៅ
រូបភាព Particularly helpful Moodlers
Thanks Mary.


Theme is Pioneer v1.4.3.1 

Moodle version is Moodle 3.1.2+ (Build: 20160923) 


Both will probably be updated tonight to latest version of Pioneer and Moodle 3.2.2.

មធ្យមភាគនៃរង្វាយតម្លៃ: -
ឆ្លើយតបទៅកាន់ Mary Evans

Re: Get user picture in CSS

ដោយ Mary Evans នៅ
រូបភាព Core developers រូបភាព Documentation writers រូបភាព Peer reviewers រូបភាព Plugin developers រូបភាព Testers

Just realised that you have asked this question before...however...since you cannot change anything in the themes files then the only solution I can suggest is for me to alter the Pioneer theme and add the user image in the layout file or files depending on how the Pioneer theme is built.

Then all you would need to do is

  1. change theme to Clean theme
  2. uninstall the Pioneer theme Site Administration > Plugins > Plugins overview
  3. install the updated theme via Site Administration > Plugins > Install plugins

The only downfall with this is that you will lose the settings that are in place now.

Cheers

Mary

មធ្យមភាគនៃរង្វាយតម្លៃ: -
ឆ្លើយតបទៅកាន់ Richard van Iwaarden

Re: Get user picture in CSS

ដោយ Gareth J Barnard នៅ
រូបភាព Core developers រូបភាព Particularly helpful Moodlers រូបភាព Plugin developers

Given "How can I make it so that i get the picture of the current logged in user with CSS?" then it cannot be done because:

Theme CSS is a 'static' thing in comparison with the dynamic nature of user sessions.  Thus the theme CSS is created (one for LTR and another for RTL) for all users.  Therefore any CSS setting / theme change to the CSS would mean a rebuild of the whole CSS per user per page load, same as having TDM off.

Therefore the only solution theme wise would be inline CSS somewhere in the markup, but then just use an 'img' tag instead.

មធ្យមភាគនៃរង្វាយតម្លៃ: -
ឆ្លើយតបទៅកាន់ Gareth J Barnard

Re: Get user picture in CSS

ដោយ Richard van Iwaarden នៅ
រូបភាព Particularly helpful Moodlers

However... I could do it with javascript ញញឹម

Let me try that. I should be able to get the element by ID or something.


What I'm trying to do is get a user picture top left and around that user  picture the course progress.


Should look like this:



មធ្យមភាគនៃរង្វាយតម្លៃ:Useful (1)