Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Seguinte...
peguei um script que pega umas fotos de uma pasta "fotos" e redimensiona para o tamanho que eu quiser.. nesse caso eu coloquei 200x170. e coloquei 2 colunas
bom até ai ok. tudo funciona.. show de bola!
Mas quando eu clico na imagem que foi redimensionada e ficou pequena, ela abre ela em tamanho real 1024x768 dentro do meu site..
queria por pra abrir como target="blank" (ou seja em outra janela) mas não consegui :wacko:
Segue o código:
fotos.php
>
<?
$sExt = "jpg,JPG,jpeg,JPEG,gif,GIF,png,PNG";
$sDir = "fotos";
$nColunas = (int) 2;
$nContador = (int) 0;
print "<table border=0 cellpadding=2 cellspacing=0>\r\n";
foreach (glob("{$sDir}/*.{{$sExt}}", GLOB_BRACE) as $sFoto)
{
print $nContador % $nColunas == 0 ? "<tr>\r\n<td>\r\n" : "<td>\r\n";
print "<a href=\"./{$sFoto}\"><img src=\"./miniaturas.php?img={$sFoto}\" /></a>";
print $nContador % $nColunas == ($nColunas - 1) ? "</td>\r\n</tr>\r\n" : "</td>\r\n";
$nContador++;
}
print "</table>";
?>
miniaturas.php
>
<?
$nLargura = "200"; // Largura Máxima da miniatura
$nAltura = "170"; // Altura Máxima da miniatura
$sImg = $_GET['img'];
$sExt = substr(strrchr($sImg, "."), 1);
$sExt = strtolower($sExt);
header ("Content-type: image/png");
switch ($sExt)
{
case "jpg" :
$rImg = imagecreatefromjpeg($sImg);
break;
case "jpeg" :
$rImg = imagecreatefromjpeg($sImg);
break;
case "gif" :
$rImg = imagecreatefromgif($sImg);
break;
case "png" :
$rImg = imagecreatefrompng($sImg);
}
$nImgLargura = imagesx($rImg);
$nImgAltura = imagesy($rImg);
if ($nImgLargura > $nImgAltura)
{
$nAltura = ($nLargura * $nImgAltura) / $nImgLargura;
}
elseif ($nImgAltura > $nImgLargura)
{
$nLargura = ($nAltura * $nImgLargura) / $nImgAltura;
}
$rMiniatura = imagecreatetruecolor($nLargura, $nAltura);
imagecopyresized($rMiniatura, $rImg, 0, 0, 0, 0, $nLargura, $nAltura, $nImgLargura, $nImgAltura);
imagepng($rMiniatura);
imagedestroy($rImg);
imagedestroy($rMiniatura);
?>
no código que esta em fotos.php ja tentei acrescentar o código em vermelho.. mas sem sucesso.. deu erro.. "T_STRING"
>
<?
$sExt = "jpg,JPG,jpeg,JPEG,gif,GIF,png,PNG";
$sDir = "fotos";
$nColunas = (int) 2;
$nContador = (int) 0;
print "<table border=0 cellpadding=2 cellspacing=0>\r\n";
foreach (glob("{$sDir}/*.{{$sExt}}", GLOB_BRACE) as $sFoto)
{
print $nContador % $nColunas == 0 ? "<tr>\r\n<td>\r\n" : "<td>\r\n";
print "<a href=\"./{$sFoto}\" **target="_blank"**><img src=\"./miniaturas.php?img={$sFoto}\" /></a>";
print $nContador % $nColunas == ($nColunas - 1) ? "</td>\r\n</tr>\r\n" : "</td>\r\n";
$nContador++;
}
print "</table>";
?>
Espero uma ajuda....
só quero que ao clicar na imagem abra ela em tamanho real em outra janela..
ja esta tudo funcionando.. mas esta abrindo na mesma janela.. :unsure:
Carregando comentários...