How to auto-resize avatars.

Get help with installation and running phpBB 3.1.x here. Please do not post bug reports, feature requests, or extension related questions here.
Anti-Spam Guide
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: phpBB 3.1.x is at its End of Life stage and support will NOT be provided after July 1st, 2018.
Locked
moonbeamlevels
Registered User
Posts: 104
Joined: Mon Mar 08, 2004 11:45 pm

How to auto-resize avatars.

Post by moonbeamlevels » Sat Jan 03, 2015 3:50 pm

running 3.1.2...i did find this:

http://forum.dion-designs.com/viewtopic.php?t=8854


but doesn't work for latest version...anyone have advice on this. also while i'm at it i want to add bbcode to add embed youtube clips to my site. anytime i add the code or follow instructions it will come up with the tags but just the url between them. maybe because of the changeover to new version so looking something that definitely works.

User avatar
KevC
Support Team Member
Support Team Member
Posts: 69360
Joined: Fri Jun 04, 2004 10:44 am
Location: Oxford, UK
Contact:

Re: How to auto-resize avatars.

Post by KevC » Sat Jan 03, 2015 4:04 pm

That code is for 3.0 so it may not be applicable to 3.1

There's already an extension request here which you can bump in the hope that someone makes it.

For youtube, you have to give it exactly what it asks for or it won't work. Check the helper line to see if you're doing that. If you think you are, post a link to a topic on your board with a youtube post, and show your BBCode with a screenshot.
-:|:- Support Request Template -:|:-
Image
Cheap UK Hosting
"In the land of the blind the little green bloke with no pupils is king - init!"

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

Re: How to auto-resize avatars.

Post by Lumpy Burgertushie » Sat Jan 03, 2015 5:25 pm

we can't help with the bbcode if we don't know what you are using. there are many different youtube bbcode possibilities.

all of the ones that worked on 3.0 also work on 3.1

robert
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?

josegf
Registered User
Posts: 9
Joined: Mon Jan 12, 2015 7:59 pm

Re: How to auto-resize avatars.

Post by josegf » Fri Sep 11, 2015 12:18 pm

I created a solution, I hope this helps you.

You'll need PHP 5.5 in your server and PHP GD library. (Probably you have, it's very common config many wordpress theme uses PHP GD library)

Then you need to edit includes/functions_upload.php, locate a function called "move_file"

Before this function you need to add the following code:

Code: Select all

	function resize_image($file, $w, $h, $crop=FALSE)
	{
		list($width, $height) = getimagesize($file);
		$r = $width / $height;
		if ($crop) {
			if ($width > $height) {
				$width = ceil($width-($width*abs($r-$w/$h)));
			} else {
				$height = ceil($height-($height*abs($r-$w/$h)));
			}
			$newwidth = $w;
			$newheight = $h;
		} else {
			if ($w/$h > $r) {
				$newwidth = $h*$r;
				$newheight = $h;
			} else {
				$newheight = $w/$r;
				$newwidth = $w;
			}
		}
		if($this->extension == "jpg") $src = imagecreatefromjpeg($file);
		if($this->extension == "png") $src = imagecreatefrompng($file);
		$dst = imagecreatetruecolor($newwidth, $newheight);
		imagecopyresampled($dst, $src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
		if($this->extension == "jpg") imagejpeg($dst,$file);
		if($this->extension == "png") imagepng($dst,$file);
	}
then in the move_file function locate the following code:

switch ($upload_mode)

just before this insert this code:

Code: Select all

$this->resize_image($this->filename,$this->upload->max_width,$this->upload->max_height);
And that's all :)

P.D. Please if you distribute/post this solution, please just mention me, thanks.

Cheers (ツ)
Jose A. Gallardo
Twitter: @Gallardo4Code

User avatar
Mick
Support Team Member
Support Team Member
Posts: 21576
Joined: Fri Aug 29, 2008 9:49 am
Location: Caerdydd

Re: How to auto-resize avatars.

Post by Mick » Fri Sep 11, 2015 12:49 pm

It would be much better and more useful if you wrote an extension to do that.
"The more connected we get the more alone we become" - Kyle Broflovski

User avatar
Sniper_E
Registered User
Posts: 789
Joined: Wed May 09, 2007 12:18 am
Location: Shreveport, Louisiana
Name: Ed Humphrey
Contact:

Re: How to auto-resize avatars.

Post by Sniper_E » Fri Sep 11, 2015 5:14 pm

There is a topic I read on large avatars somewhere in here where Arty showed the user how to adjust the size of an avatar in the css file. It was so simple it blew me away. Bypass told me I was insane for suggesting to put those huge avatars in the post area, that topic. (He was right.) If I can find that old post I'll post it.

Arty called it a work around... viewtopic.php?f=481&t=2270176#p13785181
Image
No is NEVER an Option and NEVER is the only Option when it comes to Giving Up!
:!: Sniper_E Styles | phpbbmodders :!:

User avatar
MuhClaren
Registered User
Posts: 126
Joined: Sat Feb 21, 2015 5:23 am

Re: How to auto-resize avatars.

Post by MuhClaren » Sun Oct 11, 2015 6:23 pm

I think this is queued for the next release:

https://tracker.phpbb.com/browse/PHPBB3-11207

Locked

Return to “[3.1.x] Support Forum”