News:

Join the Facebook Fan Page.

Main Menu

Avatar Size

Started by Shortie, May 21, 2010, 06:10:01 AM

Previous topic - Next topic

Shortie

Hi Al

A dumb question here

Which I cannot work out the answer to

in the index.template.php file there is this code to retrieve the members Avatar


if (!empty($context['user']['avatar']))
echo '
<p class="avatar">', $context['user']['avatar']['image'], '</p>';
echo '
<ul class="reset">
<li class="greeting">', $txt['hello_member_ndt'], ' <span>', $context['user']['name'], '</span></li>
<li><a href="', $scripturl, '?action=unread">', $txt['unread_since_visit'], '</a></li>
<li><a href="', $scripturl, '?action=unreadreplies">', $txt['show_unread_replies'], '</a></li>';


Which is fine but what I would like to do is specify the max-width of this retrieved image YET leave all the other instances of the avatar the same as the settings set in the ACP

I am sure it can be done but when I try to add style elements or a CSS tag if has no effect and the $context['user']['avatar']['image'] element has a CSS tag embedded in to it

I hope this makes sense and any help is most appreciated

Shortie

Kays

Hi, if it's only to be used in one place. Why not create another instance of ['avatar']['image'] in Load.php and add the max image size or styling to it.

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Shortie

Quote from: Kays on May 21, 2010, 08:30:07 AM
Hi, if it's only to be used in one place. Why not create another instance of ['avatar']['image'] in Load.php and add the max image size or styling to it.

True that will work

But I need to do it for a theme so needs to be done in the Index.template file and CSS file

Shortie

P.S. thanks for the input


Kays

#3
The other option might be to use ['avatar']['href']. I've not used it so I don't know if it applies to the three types of avatars


<img src="', $context['user']['avatar']['href'], '" class="whatever" alt="" />

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Shortie

Quote from: Kays on May 21, 2010, 08:57:01 AM
The other option might be to use ['avatar']['href']. I've not used it so I don't know if it applies to the three types of avatars


<img src="', $context['user']['avatar']['href'], '" class="whatever" alt="" />


Think that might be it Kays

I have been poking around the SPortal code and they are using it like that so will dig deeper and see what I come up with

Thanks again

More ideas welcome though :D :D

Shortie

Sorry for double post

That nailed it Kays - you are a Star

The code is as follows

{
if (!empty($context['user']['avatar']))
echo '
<p class="avatar"><img src="', $context['user']['avatar']['href'], '"style="max-width:100px"" alt="" /></p>';
echo '


This will keep the perspective if it not square and will only resize if the Avatar is too large

Thanks Again

Shortie

Kays

Cool, that's something I was wondering about and I never thought of using max-width for that. :)

It looks like we both learn something from this.


If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Shortie

Thanks to you to :D

Here it is in action - also if there are mod reports or maintenance mode etc the text just wraps around the Avatar

For a full working demo just click the Sig

Shortie


Kays

Quote
For a full working demo just click the Sig

I'll take you word on it as I'm not registered there. :)

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Advertisement: