avatar autoresize

Looking for an Extension? Have an Extension request? Post your request here for help. (Note: This forum is community supported; while there is an Extensions Development Team, said team does not dedicate itself to handling requests in this forum)
Ideas Centre
danny94
Registered User
Posts: 7
Joined: Tue May 10, 2016 2:14 pm

Re: avatar autoresize

Post by danny94 » Tue May 10, 2016 2:17 pm

Something new on it ?

voom
Registered User
Posts: 59
Joined: Tue Mar 22, 2016 1:31 am

Re: avatar autoresize

Post by voom » Wed Jul 20, 2016 12:03 am

josegf wrote: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
This is actually great, except as others mentioned it breaks attachment upload. But there is a simple solution :)

The additional code goes within the move_file function. At the beginning add $mode to the variables this function reads:

Code: Select all

global $user, $phpbb_root_path, $mode;
Then replace the second code-snippet from above with:

Code: Select all

if ($mode == 'avatar') { $this->resize_image($this->filename,$this->upload->max_width,$this->upload->max_height); }
Now the resize function will only affect the avatar-uploads...

danny94
Registered User
Posts: 7
Joined: Tue May 10, 2016 2:14 pm

Re: avatar autoresize

Post by danny94 » Tue Aug 16, 2016 3:14 pm

Thanks man,
had this problem with broken attachment upload with this function. Now it works like a charm.
Thanks.

designer2k2
Registered User
Posts: 5
Joined: Tue Jan 04, 2011 7:16 am
Location: Austria
Contact:

Re: avatar autoresize

Post by designer2k2 » Wed Jan 04, 2017 3:55 pm

Hello,

how does this apply for 3.2?

there is no includes/functions_upload.php anymore...

User avatar
Neuropass
Registered User
Posts: 1158
Joined: Fri Apr 17, 2009 2:02 pm
Location: SciTE4AutoIt3

Re: avatar autoresize

Post by Neuropass » Fri Jan 06, 2017 11:21 pm

designer2k2 wrote:
Wed Jan 04, 2017 3:55 pm
Hello,

how does this apply for 3.2?

there is no includes/functions_upload.php anymore...
Scroll to the bottom:
http://sitesplat.com/phpBB3/viewtopic.p ... 476#p16476

designer2k2
Registered User
Posts: 5
Joined: Tue Jan 04, 2011 7:16 am
Location: Austria
Contact:

Re: avatar autoresize

Post by designer2k2 » Sat Jan 07, 2017 5:10 am

The BBavatarResize looks interesting, but also a bit overkill for just resizing an uploaded image.

Also i do not want to buy a theme, i just want a extension that works on a 3.2 prosilver based forum...

EDIT:

searched a bit, and found this:

core.avatar_driver_upload_move_file_before

its inside phpbb/avatar/driver/upload.php "Before moving new file in place (and eventually overwriting the existing avatar with the newly uploaded avatar)"

That sounds like the right spot, or?

User avatar
Anv@r.all
Registered User
Posts: 191
Joined: Sun Sep 15, 2013 11:49 am
Location: bb3.mobi
Name: Anvar Stybaev
Contact:

Re: avatar autoresize

Post by Anv@r.all » Sun Feb 12, 2017 4:51 pm

[DEV/Beta] More extensions

Hopefully Google correctly translate my text// I do not support in private messages!

User avatar
girello
Registered User
Posts: 169
Joined: Tue Mar 30, 2010 8:53 am
Location: italia
Contact:

Re: avatar autoresize

Post by girello » Sun Feb 12, 2017 5:09 pm

hi anv! i download and install it!
i try it but i have this error:

[phpBB Debug] PHP Warning: in file [ROOT]/ext/bb3mobi/AvatarUpload/core/resize.php on line 69: include(./includes/functions_upload.php): failed to open stream: No such file or directory
[phpBB Debug] PHP Warning: in file [ROOT]/ext/bb3mobi/AvatarUpload/core/resize.php on line 69: include(./includes/functions_upload.php): failed to open stream: No such file or directory
[phpBB Debug] PHP Warning: in file [ROOT]/ext/bb3mobi/AvatarUpload/core/resize.php on line 69: include(): Failed opening './includes/functions_upload.php' for inclusion (include_path='.:/php5.6/lib/php/')

Fatal error: Class 'fileupload' not found in /web/htdocs/www.photolandia.net/home/ext/bb3mobi/Av ... resize.php on line 72
http://www.photolandia.net
version phpbb 3.2

User avatar
Anv@r.all
Registered User
Posts: 191
Joined: Sun Sep 15, 2013 11:49 am
Location: bb3.mobi
Name: Anvar Stybaev
Contact:

Re: avatar autoresize

Post by Anv@r.all » Sun Feb 12, 2017 5:35 pm

In phpBB3.2 no functions_upload.php

Well, we find))
[DEV/Beta] More extensions

Hopefully Google correctly translate my text// I do not support in private messages!

User avatar
Anv@r.all
Registered User
Posts: 191
Joined: Sun Sep 15, 2013 11:49 am
Location: bb3.mobi
Name: Anvar Stybaev
Contact:

Re: avatar autoresize

Post by Anv@r.all » Sun Feb 12, 2017 6:35 pm


User avatar
girello
Registered User
Posts: 169
Joined: Tue Mar 30, 2010 8:53 am
Location: italia
Contact:

Re: avatar autoresize

Post by girello » Sun Feb 12, 2017 6:38 pm

Anv@r.all wrote:
Sun Feb 12, 2017 6:35 pm
Extension Avatar Upload Resize for phpBB3.2
tnx anvar, now i try it
http://www.photolandia.net
version phpbb 3.2

deanmoke
Registered User
Posts: 23
Joined: Tue May 20, 2008 9:05 am

Re: avatar autoresize

Post by deanmoke » Mon Mar 06, 2017 10:17 am

Anv@r.all wrote:
Sun Feb 12, 2017 6:35 pm
Extension Avatar Upload Resize for phpBB3.2
Works for me!
Thanks Anv@r.all
Dean

epi4dogs
Registered User
Posts: 13
Joined: Tue Apr 25, 2017 1:31 am

Re: avatar autoresize

Post by epi4dogs » Tue Apr 25, 2017 10:35 pm

Anv@r.all wrote:
Sun Feb 12, 2017 6:35 pm
Extension Avatar Upload Resize for phpBB3.2
Hi Anvar,

I was excited to find your resize & crop extension here http://bb3.mobi/forum/viewtopic.php?t=234 but after installing on 3.2 I get the following error:

[phpBB Debug] PHP Warning: in file [ROOT]/ext/bb3mobi/AvatarUpload/core/resize.php on line 83: include(./includes/functions_upload.php): failed to open stream: No such file or directory
[phpBB Debug] PHP Warning: in file [ROOT]/ext/bb3mobi/AvatarUpload/core/resize.php on line 83: include(./includes/functions_upload.php): failed to open stream: No such file or directory
[phpBB Debug] PHP Warning: in file [ROOT]/ext/bb3mobi/AvatarUpload/core/resize.php on line 83: include(): Failed opening './includes/functions_upload.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php')

Fatal error: Class 'fileupload' not found in /home/bigbl2/public_html/.../phpBB/ext/bb3mobi/AvatarUpload/core/resize.php on line 86

Any ideas?

Post Reply

Return to “Extension Requests”

Who is online

Users browsing this forum: No registered users and 9 guests