Is there an easy way to get avatars to auto resize in 3.0.12 prosilver?

Get help with installation and running phpBB 3.0.x here. Please do not post bug reports, feature requests, or MOD-related questions here.
Ideas Centre
Forum rules
END OF SUPPORT: 1 January 2017 (announcement)
Locked
Bruce Banner
Registered User
Posts: 635
Joined: Thu Sep 25, 2014 10:36 am

Is there an easy way to get avatars to auto resize in 3.0.12 prosilver?

Post by Bruce Banner » Tue Dec 02, 2014 2:03 am

Whether they're uploaded or remotely linked to, I'd like them to auto resize to a fixed width. Is there an easy way I can do that? I imagine there has to be. From my Googling, I see that people have been asking similar questions for the last several years.

User avatar
Oyabun1
Former Team Member
Posts: 23162
Joined: Sun May 17, 2009 1:05 pm
Location: Australia
Name: Bill

Re: Is there an easy way to get avatars to auto resize in 3.0.12 prosilver?

Post by Oyabun1 » Tue Dec 02, 2014 2:37 am

You would need a MOD for that. Have a look in the Modifications Database and if you can't find one that is suitable you could post in [3.0.x] MOD Requests.
                      Support Request Template
3.0.x: Knowledge Base Styles Support MOD Requests
3.1.x: Knowledge BaseStyles SupportExtension Requests

Bruce Banner
Registered User
Posts: 635
Joined: Thu Sep 25, 2014 10:36 am

Re: Is there an easy way to get avatars to auto resize in 3.0.12 prosilver?

Post by Bruce Banner » Tue Dec 02, 2014 4:19 am

Oyabun1 wrote:You would need a MOD for that. Have a look in the Modifications Database and if you can't find one that is suitable you could post in [3.0.x] MOD Requests.
Thanks. Found the solution.

Open includes/functions_display.php

Just before this line of code,

Code: Select all

return '<img src="' . (str_replace(' ', '%20', $avatar_img)) . '" width="' . $avatar_width . '" height="' . $avatar_height . '" alt="' . ((!empty($user->lang[$alt])) ? $user->lang[$alt] : $alt) . '" />';
place these lines of code,

Code: Select all

if($avatar_width > $avatar_height)
    {
        if($avatar_width > 200)
        {
            $divisor = floatval($avatar_width / 200) ;
            $avatar_width = $avatar_width / $divisor ;
            $avatar_height = $avatar_height / $divisor ;       
        }
    }
    else
    {
        if($avatar_width > 200)
        {
            $divisor = floatval($avatar_width / 200) ;
            $avatar_width = $avatar_width / $divisor ;
            $avatar_height = $avatar_height / $divisor ;
        }
    }
This worked perfectly for me. Now whether I upload from my computer, another site, remotely link, whether I'm in the UCP, my profile page, a PM, or topic view, my avatar's no wider than 200. I picked 200 just cos it suited me. I'm sure it'll work for any number.

User avatar
Oyabun1
Former Team Member
Posts: 23162
Joined: Sun May 17, 2009 1:05 pm
Location: Australia
Name: Bill

Re: Is there an easy way to get avatars to auto resize in 3.0.12 prosilver?

Post by Oyabun1 » Tue Dec 02, 2014 7:14 am

That will work provided the images aren't animated .gif images or .png images which use transparency. Those images it will break.
                      Support Request Template
3.0.x: Knowledge Base Styles Support MOD Requests
3.1.x: Knowledge BaseStyles SupportExtension Requests

Bruce Banner
Registered User
Posts: 635
Joined: Thu Sep 25, 2014 10:36 am

Re: Is there an easy way to get avatars to auto resize in 3.0.12 prosilver?

Post by Bruce Banner » Tue Dec 02, 2014 5:05 pm

Oyabun1 wrote:That will work provided the images aren't animated .gif images or .png images which use transparency. Those images it will break.
Actually, it worked fine for animated images. I remotely linked to one, and uploaded one from another site, and both resized perfectly. I'll check now if it works for PNGs.

EDIT: Yep, just remotely uploaded a png and it was fine, no problem. Why did you think those formats would break?

User avatar
Oyabun1
Former Team Member
Posts: 23162
Joined: Sun May 17, 2009 1:05 pm
Location: Australia
Name: Bill

Re: Is there an easy way to get avatars to auto resize in 3.0.12 prosilver?

Post by Oyabun1 » Tue Dec 02, 2014 8:53 pm

I didn't read the code properly. I thought it was to resize the image rather than the displayed size.
                      Support Request Template
3.0.x: Knowledge Base Styles Support MOD Requests
3.1.x: Knowledge BaseStyles SupportExtension Requests

Bruce Banner
Registered User
Posts: 635
Joined: Thu Sep 25, 2014 10:36 am

Re: Is there an easy way to get avatars to auto resize in 3.0.12 prosilver?

Post by Bruce Banner » Tue Dec 02, 2014 9:41 pm

Oyabun1 wrote:I didn't read the code properly. I thought it was to resize the image rather than the displayed size.
Oh, OK. I just read the code myself and the part under "else" looks identical to the part above "else". Why is the code repeated?

Bruce Banner
Registered User
Posts: 635
Joined: Thu Sep 25, 2014 10:36 am

Re: Is there an easy way to get avatars to auto resize in 3.0.12 prosilver?

Post by Bruce Banner » Wed Dec 03, 2014 10:38 am

Bump.

User avatar
Lumpy Burgertushie
Registered User
Posts: 66486
Joined: Mon May 02, 2005 3:11 am
Contact:

Re: Is there an easy way to get avatars to auto resize in 3.0.12 prosilver?

Post by Lumpy Burgertushie » Wed Dec 03, 2014 3:27 pm

you would have to ask whoever created the code in the first place. where did you find it?


robrt
I'm baaaaaccckkkk. still doing work on donation basis. PM your needs.

Premium phpBB 3.2 Styles by PlanetStyles.net

If a tree falls in the forest and nobody is there, does it make a sound?

User avatar
RaythXC
Registered User
Posts: 150
Joined: Wed Jun 13, 2012 1:23 pm

Re: Is there an easy way to get avatars to auto resize in 3.0.12 prosilver?

Post by RaythXC » Wed Dec 03, 2014 4:07 pm

I imagine that whoever wrote it probably meant to have a section that did something different is heigh > width. As it is you could just have:

Code: Select all

        if($avatar_width > 200)
        {
            $divisor = floatval($avatar_width / 200) ;
            $avatar_width = $avatar_width / $divisor ;
            $avatar_height = $avatar_height / $divisor ;
        }
        
without anything from before o after.

Bruce Banner
Registered User
Posts: 635
Joined: Thu Sep 25, 2014 10:36 am

Re: Is there an easy way to get avatars to auto resize in 3.0.12 prosilver?

Post by Bruce Banner » Wed Dec 03, 2014 5:03 pm

Lumpy Burgertushie wrote:you would have to ask whoever created the code in the first place. where did you find it?


robrt
A really old post from here. I think from 5 or so years ago. Doesn't matter really. It works fine. Thanks.
RaythXC wrote:I imagine that whoever wrote it probably meant to have a section that did something different is heigh > width. As it is you could just have:

Code: Select all

        if($avatar_width > 200)
        {
            $divisor = floatval($avatar_width / 200) ;
            $avatar_width = $avatar_width / $divisor ;
            $avatar_height = $avatar_height / $divisor ;
        }
        
without anything from before o after.
Thanks.

Locked

Return to “[3.0.x] Support Forum”