avatar thumbnail in viewtopic.php

Looking for a MOD? Have a MOD request? Post here for help. (Note: This forum is community supported; phpBB does not have official MOD authors)
Anti-Spam Guide
Locked
Jhonne
Registered User
Posts: 21
Joined: Sat Feb 27, 2010 7:36 pm

avatar thumbnail in viewtopic.php

Post by Jhonne » Thu May 06, 2010 3:13 pm

I have made so that the user avatar is shown as a big image in the profile. However I dont want the avatar to be shown with that size in posts on the forum. I have found a mod that can make a thumbnail of the avatar in the memberlist.php using this code. I need help with a mod that will make this work in the viewtopic also.

Code: Select all

'USER_AVATAR'		=> get_user_avatar($data['user_avatar'], $data['user_avatar_type'], $data['user_avatar_width'], $data['user_avatar_height']),
		
'USER_AVATAR_THUMB'	=> ($data['user_avatar']) ? get_user_avatar($data['user_avatar'], $data['user_avatar_type'], ($data['user_avatar_width'] > $data['user_avatar_height']) ? 25 : (25 / $data['user_avatar_height']) * $data['user_avatar_width'], ($data['user_avatar_height'] > $data['user_avatar_width']) ? 25 : (25 / $data['user_avatar_width']) * $data['user_avatar_height']) : '',

Jhonne
Registered User
Posts: 21
Joined: Sat Feb 27, 2010 7:36 pm

Re: avatar thumbnail in viewtopic.php

Post by Jhonne » Sat May 08, 2010 7:39 am

anyone?

User avatar
RMcGirr83
Recognised Extension Developer
Posts: 21034
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr
Contact:

Re: avatar thumbnail in viewtopic.php

Post by RMcGirr83 » Sat May 08, 2010 11:30 am

You would want to change this line in viewtopic.php

Code: Select all

				'avatar'		=> ($user->optionget('viewavatars')) ? get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $row['user_avatar_width'], $row['user_avatar_height']) : '',
There are two lines of similar (one is for Guests and one for users) so you should probably change both of them.
In times of change, learners inherit the earth, while the learned find themselves beautifully equipped to deal with a world that no longer exists - Eric Hoffer
Former Modifications/Extensions Team Member | My extensions
Appreciate the extensions/mods/support then buy me a beer
All requests for support via PM will be ignored

Jhonne
Registered User
Posts: 21
Joined: Sat Feb 27, 2010 7:36 pm

Re: avatar thumbnail in viewtopic.php

Post by Jhonne » Sat May 08, 2010 3:42 pm

Yes I saw those line and I tried to replace the codes there the problem is that the code that I use in memberlist.php does not work in viewtopic.php. I dont know what I must do to make this work.

User avatar
RMcGirr83
Recognised Extension Developer
Posts: 21034
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr
Contact:

Re: avatar thumbnail in viewtopic.php

Post by RMcGirr83 » Sat May 08, 2010 4:31 pm

In the code for memberlist.php you have these (snipped btw)

Code: Select all

$data
replace those with

Code: Select all

$row
and that should do it.

so that it looks like this when done (for both please)

Code: Select all

'avatar'      => ($user->optionget('viewavatars')) ? get_user_avatar($row['user_avatar'], $row['user_avatar_type'], ($row['user_avatar_width'] > $row['user_avatar_height']) ? 25 : (25 / $row['user_avatar_height']) * $row['user_avatar_width'], ($row['user_avatar_height'] > $row['user_avatar_width']) ? 25 : (25 / $row['user_avatar_width']) * $row['user_avatar_height']) : '',
In times of change, learners inherit the earth, while the learned find themselves beautifully equipped to deal with a world that no longer exists - Eric Hoffer
Former Modifications/Extensions Team Member | My extensions
Appreciate the extensions/mods/support then buy me a beer
All requests for support via PM will be ignored

Jhonne
Registered User
Posts: 21
Joined: Sat Feb 27, 2010 7:36 pm

Re: avatar thumbnail in viewtopic.php

Post by Jhonne » Sun May 09, 2010 5:25 pm

Works perfectly, thanks for the help!

User avatar
RMcGirr83
Recognised Extension Developer
Posts: 21034
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr
Contact:

Re: avatar thumbnail in viewtopic.php

Post by RMcGirr83 » Mon May 10, 2010 10:01 am

Not a problem.

Good luck!! :)
In times of change, learners inherit the earth, while the learned find themselves beautifully equipped to deal with a world that no longer exists - Eric Hoffer
Former Modifications/Extensions Team Member | My extensions
Appreciate the extensions/mods/support then buy me a beer
All requests for support via PM will be ignored

User avatar
the seeker!
Registered User
Posts: 33
Joined: Sun Aug 22, 2010 6:17 pm

Re: avatar thumbnail in viewtopic.php

Post by the seeker! » Tue Dec 07, 2010 5:06 pm

After this edit, I set mine to 40, but i get dis at d top of my page while viewing SOME topics, and d magnification of those pages are high (as if zoomed) pls help

Code: Select all

[phpBB Debug] PHP Notice: in file /viewtopic.php on line 1150: Division by zero
[phpBB Debug] PHP Notice: in file /viewtopic.php on line 1150: Division by zero
d line 1150 coincides with one of the edit lines. :roll:

User avatar
Alien_Time
Registered User
Posts: 389
Joined: Fri Dec 31, 2010 7:08 am

Re: avatar thumbnail in viewtopic.php

Post by Alien_Time » Sun Jan 08, 2012 12:16 am

Hi RMcGirr83,

I am trying to do the same...I increased the avatar size to 150 x 150 in ACP and this is the size that shows in the user profile page. however, I want the size in the posts to be only 75 X 75. So, I replaced two sections of the code for 'avatar' in viewtopic.php to the ones you had suggested:

Code: Select all

				'avatar'      => ($user->optionget('viewavatars')) ? get_user_avatar($row['user_avatar'], $row['user_avatar_type'], ($row['user_avatar_width'] > $row['user_avatar_height']) ? 75 : (75 / $row['user_avatar_height']) * $row['user_avatar_width'], ($row['user_avatar_height'] > $row['user_avatar_width']) ? 75 : (75 / $row['user_avatar_width']) * $row['user_avatar_height']) : '',	
But, when I do this, I am now receiving this error at the top of some forum pages (viewtopic.php):
[phpBB Debug] PHP Warning: in file [ROOT]/viewtopic.php on line 1176: Division by zero
[phpBB Debug] PHP Warning: in file [ROOT]/viewtopic.php on line 1176: Division by zero
[phpBB Debug] PHP Warning: in file [ROOT]/viewtopic.php on line 1176: Division by zero
[phpBB Debug] PHP Warning: in file [ROOT]/viewtopic.php on line 1176: Division by zero
[phpBB Debug] PHP Warning: in file [ROOT]/viewtopic.php on line 1176: Division by zero
[phpBB Debug] PHP Warning: in file [ROOT]/viewtopic.php on line 1176: Division by zero
[phpBB Debug] PHP Warning: in file [ROOT]/viewtopic.php on line 1176: Division by zero
[phpBB Debug] PHP Warning: in file [ROOT]/viewtopic.php on line 1176: Division by zero
When the above code change is added, I can see that the avatars are re-sized to 75 x 75 in posts but however it shows the above error at the top of the page..How to fix this plz?

User avatar
4_seven
I've Been Banned!
Posts: 5155
Joined: Wed Apr 30, 2008 1:41 am

Re: avatar thumbnail in viewtopic.php

Post by 4_seven » Sun Jan 08, 2012 1:11 am

find inline

Code: Select all

get_user_avatar
replace inline with

Code: Select all

@get_user_avatar
Current Mods | Mod Base | php(BB) programming | No help via PM

User avatar
Alien_Time
Registered User
Posts: 389
Joined: Fri Dec 31, 2010 7:08 am

Re: avatar thumbnail in viewtopic.php

Post by Alien_Time » Sun Jan 08, 2012 2:15 am

thank you 4_seven....that did it..its now fixed.

Locked

Return to “[3.0.x] MOD Requests”