Página 1 de 1

Auto redimensionar los avatares

Publicado: 07 Mar 2013, 20:18
por nadlor
Estimados,

E visto que para poner una imagen de avatar, la misma debe ajustarse al tamaño maximo especificados, por ejemplo 200x150px con 64kb de peso. Para ello, el usuario debe usar alguna herramienta externa para redimensionar su avatar, pues sino no podra subir la imagen a su perfil.

Quisiera saber si es posible que el usuario suba cualquier imagen desde el pc de cualquier tamaño, y automaticamente se redimensione al tamaño maximo.

Por ejemplo, sube una imagen de 1366 x 768 pixeles. Automaticamente se "redimensiona" proporcionalmente al maximo de 200x150px, que sea transparente para el usuario!!!

Eso sera posible? Mucha gente tiene escasa idea de lo que es un pixel, o que herramientas usar para cambiar el tamaño de una imagen.

Se que si se puede porque lo e visto en otro foro, pero no se que MOD se habra usado, o que linea de codigo modificado. Se puede?


Muchas gracias!

Agrego: E visto que ya otra gente hizo la misma pregunta, pero son preguntas viejas, y ya e probado algunos de esos MODS que mencionan, pero son para versiones mas antiguas de PHPBB. Y no me funcionaron.

URL: http://clubxr125.com.ar/
Plantilla(s) usuada(s): PROSILVER
MODs instalados: Advanced BBCode Box 3 (aka ABBC3), phpBB Social Network, Alternate Login, UMIL - Unified Mod Install Library, Share On
Versión de phpBB: 3.0.11
Servidor: http://mihwd.net, es de pago
Si es una actualización desde otra versión: NO
Si es una conversión desde otro tipo de Foro: NO

Re: Auto redimensionar los avatares

Publicado: 07 Mar 2013, 23:21
por towen
El mod que pusiste en tu otro tema (avatar true resize) funciona perfectamente en cualquier versión.

Re: Auto redimensionar los avatares

Publicado: 07 Mar 2013, 23:49
por nadlor
Al instalar dice:

One or more install actions failed. Please review the actions below, make any adjustments and retry. You may continue with the installation even though some of the actions failed. This is not recommended and may cause your board to not function correctly.

Código: Seleccionar todo

Find
if (!$this->upload->valid_dimensions($this))
Replace With
if (!$this->upload->valid_dimensions($this) && $_GET['mode'] != 'avatar')
Success
Find
/**
* Performing additional checks
*/
Add Before
/**
* Resize avatar with the true diemensions
*/
    function resize_avatar()
    {
	    if ( $_GET['mode'] == "avatar" ) {
	 	    $limite_largeur = $this->upload->max_width;
	 	    $limite_hauteur = $this->upload->max_height;
		
		    $size = getimagesize($this->destination_file);
		
		    $largeur = $size[0];
		    $hauteur = $size[1];

		    if($hauteur > $limite_hauteur OR $largeur > $limite_largeur)
		    {
			     if($largeur > $limite_largeur)
			     {
			        $hauteur = $hauteur / ($largeur / $limite_largeur);
			        $largeur = $limite_largeur;
			     }
			     if($hauteur > $limite_hauteur)
			     {
			        $largeur = $largeur / ($hauteur / $limite_hauteur);
			        $hauteur = $limite_hauteur;
			     }

				 $destination = imagecreatetruecolor($largeur, $hauteur);
				
			     if ( $this->extension == "jpg" || $this->extension == "jpeg" )
				 {
				 $source = imagecreatefromjpeg($this->destination_file);
				 }
			     elseif ( $this->extension == "png" )
				 {
				 $source = imagecreatefrompng($this->destination_file);
				 $color = imagecolorallocatealpha($destination, 0, 0, 0, 127);
				 imagefill($destination, 0, 0, $color);
				 }
			     elseif ( $this->extension == "gif" )
				 {
				 $source = imagecreatefromgif($this->destination_file);
				 }

			     imagecopyresampled($destination, $source, 0, 0, 0, 0, $largeur, $hauteur, $size[0], $size[1]);

				 if ( $this->extension == "jpg" || $this->extension == "jpeg" )
				 {
				 imagejpeg($destination, $this->destination_file);
				 }
			     elseif ( $this->extension == "png" )
				 {
				 imagealphablending($destination, true);
				 imagesavealpha($destination, true);
				 imagepng($destination, $this->destination_file);
				 }
			     elseif ( $this->extension == "gif" )
				 {
				 imagegif($destination, $this->destination_file);
				 }
		    }
	    }
    }
[highlight=#ff4040]The Find specified by the MOD could not be found
[/highlight]Find
phpbb_chmod($this->destination_file, $chmod);
Add Before
if ( $_GET['mode'] == 'avatar' ) $this->resize_avatar();
[highlight=#ff4040]The Find specified by the MOD could not be found[/highlight]

Le doy al boton "Force Install"

Código: Seleccionar todo

You forced the installation of this MOD even though there were errors installing the MOD. Your board may be broken. Please note the actions that failed below and correct them.

Cuando voy a intentar subir una imagen mas "pesada" como avatar, me dice:
El avatar debe estar entre 0 y 65 KiB.
O sea, no me deja.
Borre la cache del estilo, tambien cache en pestaña general. Desinstale e instale el Prosilver.

Pero igual, no funciona el MOD Resize.