How to retrieve the users avatar url?

Started by AzorMachine, December 18, 2014, 01:37:06 PM

Previous topic - Next topic

AzorMachine

Hello everyone.
I know some may think the answer to my question is $context['user']['avatar']['image'], but it returns me a img src, that I don't want to. All I want is the url of the avatar image. Is there another function for it? And if not, this function that returns me the img src, is declared in which file in SMF? Because a quick edit in it would solve my problem, but I can't fix what I can't find.
Best Regards.

Diego Andrés


SMF Tricks - Free & Premium Responsive Themes for SMF.

AzorMachine

Quote from: Diego Andrés on December 18, 2014, 01:39:12 PM
Use href/url instead of image

Thanks, it was it.
But now, the image isn't showing. This is the code i'm using.

echo '<div id="avatar" style="width: 100px; height: 100px; background-image: url(',$context['user']['avatar']['href'],') no-repeat;"></div>';

Sir Osis of Liver




echo '<div id="avatar" style="width: 100px; height: 100px; background-image: url(', $context['user']['avatar']['href'] ,'); background-repeat: no-repeat;"></div>';


Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Arantor

For the record it does need to be $context['user']['avatar']['href'] (not anything else) and using width/height will not cause it to be resized but rather cropped to that size.

Perhaps max-width and max-height would be better?

Hj Ahmad Rasyid Hj Ismail

Don't forget to globalize $context wherever you are using it, if it is not yet globalized.

Advertisement: