Ir para conteúdo

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

twpesquisa

thumbnail

Recommended Posts

Pessoal, não sei se é aqui ou na área de javascrip...Mas é o seguinte:um certo dia achei na net um thumbnail.php ( http://www.hotscripts.com/Detailed/18727.html ) e hoje resolvi usar mas percebi que existe um bug.Quando clico na imagem, ele primeiro aparce pequeno e após fechar a clicar novamente ele exibe o tamanho real da imagem, acredido que seja problema no javascript. Abaixo segue o código:thumbnail.php

function thumbnail ($gdver, $src, $maxw=190) {		$gdarr = array (1,2);	for ($i=0; $i<count($gdarr); $i++) {		if ($gdver != $gdarr[$i]) $test.="|";	}	$exp = explode ("|", $test);	if (count ($exp) == 3) {		ErrorImage ("Versão incorreta do GD!");	}	if (!function_exists ("imagecreate") || !function_exists ("imagecreatetruecolor")) {		ErrorImage ("Nenhuma função para criar imagens!");	}	$size = @getimagesize ($src);	if (!$size) {		ErrorImage ("Arquivo da imagem não encontrado!");	} else {		if ($size[0] > $maxw) {			$newx = intval ($maxw);			$newy = intval ($size[1] * ($maxw / $size[0]));		} else {			$newx = $size[0];			$newy = $size[1];		}		if ($gdver == 1) {			$destimg = imagecreate ($newx, $newy );		} else {			$destimg = @imagecreatetruecolor ($newx, $newy ) or die (ErrorImage ("Não pode usar GD2 aqui!"));		}				if ($size[2] == 1) {			if (!function_exists ("imagecreatefromgif")) {				ErrorImage ("Imagem GIF não pode ser usada!");			} else {				$sourceimg = imagecreatefromgif ($src);				if ($gdver == 1)					imagecopyresized ($destimg, $sourceimg, 0,0,0,0, $newx, $newy, $size[0], $size[1]);				else					@imagecopyresampled ($destimg, $sourceimg, 0,0,0,0, $newx, $newy, $size[0], $size[1]) or die (ErrorImage ("Não pode usar GD2 aqui!"));				header ("content-type: image/gif");				imagegif ($destimg);			}		}		elseif ($size[2]==2) {			$sourceimg = imagecreatefromjpeg ($src);			if ($gdver == 1)				imagecopyresized ($destimg, $sourceimg, 0,0,0,0, $newx, $newy, $size[0], $size[1]);			else				@imagecopyresampled ($destimg, $sourceimg, 0,0,0,0, $newx, $newy, $size[0], $size[1]) or die (ErrorImage ("Não pode usar GD2 aqui!"));			header ("content-type: image/jpeg");			imagejpeg ($destimg);		}		elseif ($size[2] == 3) {			$sourceimg = imagecreatefrompng ($src);			if ($gdver == 1)				imagecopyresized ($destimg, $sourceimg, 0,0,0,0, $newx, $newy, $size[0], $size[1]);			else				@imagecopyresampled ($destimg, $sourceimg, 0,0,0,0, $newx, $newy, $size[0], $size[1]) or die (ErrorImage ("Não pode usar GD2 aqui!"));			header ("content-type: image/png");			imagepng ($destimg);		}		else {			ErrorImage ("Tipo de imagem não compatível!");		}	}	imagedestroy ($destimg);	imagedestroy ($sourceimg);}thumbnail ($_GET["gd"], $_GET["src"], $_GET["maxw"]);
Código java script:

Mode de usar:<script>function abre(imagem){ xImage = new Image() xImage.src = imagem x = xImage.width + 25 y = xImage.height + 25 window.open(imagem, "popup", "width="+x+",height="+y+",toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no")}</script>

<img src="/path/to/thumbnail.php?gd=N&src=/path/to/image.EXT&maxw=NNN" />onde N = a versão da library GD (valores 1 ou 2) EXT = a extensão do arquivo da imagem (os valores podem ser gif (se o gd = 2), jpg e png) NNN = o tamanho máximo da largura do thumbnailalguem tem ideia do que pode ser ? :rolleyes:

Compartilhar este post


Link para o post
Compartilhar em outros sites

tem um script que o fabyo postou muito bomeu uso ele adaptado ao meu sistema de programação, mas da uma procurada no forum (deve estar no laboratorio de scripts)

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.