Skip to main content


Adding Libravatar support


@Friendica Support @Mike

I would like to add Libravatar lookup as an optional replacement for Gravatar in ~friendica ~friendica. But I have some questions how it would be done best:

#Libravatar is a #federated #avatar hosting service. There is a central service comparable to #Gravatar, but you could also run your own instance of it. Unfortunately it is not so easy to set the hosting service up on your own server, but I would like to add support to query Libravatar. There exists a PHP class to query Libravatar that I would need to use. It is MIT licensed so that should be no problem to include. It requires PHP5.3 would that be a problem?

There is a config option to enable Gravatar support right now. So I thought if it would make sense to implement Gravatar support and then also Libravatar support as plugins?

I just looked shortly into the code and it seems that there is only 1 function I would need to hook into and this function is only used in 2 places. I have thought to rename the function gravatar_img($email) in include/network.php to a more generic avatar_img($email) and placing the hook inside that function that the plugin would use then.
I would also like to add options to the Gravatar plugin then to select the image-rating and default-image. Right now friendica's Gravatar implementation allows pg-rated images hardcoded. Libravatar only allows g-rated images and also only looks these up as a fallback at Gravatar. So no pg-rated images would be possible with the Libravatar plugin anymore as a downside. And a maybe bit slower lookup to find the right hosting service trough DNS or if it needs to fall back to Gravatar. But I don't think that should be a problem and the admin could anyway switch back to Gravatar-only lookup with the Gravatar plugin.

In include/Scrape.php the function gravatar_img() is also called once, but there is no check if $use_gravatar is enabled at all. Was there a special reason for that? Would it break if no avatar is returned?

How would a migration work? Friendica core and the addons would need to be updated at the same time and then there should be an update function that checks if $use_gravatar was enabled before and then enable the Gravatar plugin? Would that work somehow automatically? What if someone forgets to update the addons at the same time?
What would be the right way to check that only one of these two plugins is loaded at any time?

Would like to hear your comments about how this should be implemented in a correct way.

Thank you very much!

in reply to Klaus Weidenbach

I have just opened two pull-requests for friendica and friendica-addons at github. Right now it only took the Gravatar support from core and made it a plugin.
Could you review this and see if it fits to the greater design of friendica and tell me if I need to change something.
When this is working I will create the Libravatar plugin.
in reply to Klaus Weidenbach

I left a note in the pull request. Basically we want to ensure that it returns a valid photo even if there are no plugins. The valid fallback photo is $url/images/person-175.jpg


Picture upload problems


Oh damn, so late again. :-( Actually I wanted to fix my picture uploading problems in ~friendica ~friendica, but now I wrote so long on the log of the parent's meeting in kindergarten today. At least that is finished tonight. ;-)


Did someone else had such problems uploading pictures to ~friendica ~friendica and has a guess what to try?

mod/photos.php: photos_post(): album=  newalbum=
photos: upload: received file: mememe01.png as /tmp/phpopZEel 28065 bytes
mod/photos.php: photos_post(): loading the contents of /tmp/phpopZEel
mod/photos.php: photos_post(): unable to process image


So far I just know, that the webserver has write permission to the photos folder and SELinux is also not the problem.

in reply to Klaus Weidenbach

Thanks for these hints. I will check them when I am home this evening.
in reply to Klaus Weidenbach

Thank you very much @Mike I have found the problem. Was again a configuration mistake on my side. :-/ After I used the js_upload plugin I got an error message in the httpd error log finally that pointed me to the problem. I forgot to allow /tmp in my open_basedir configuration.