PHP interesse |
|
He,
Het volgende script resized images automatisch als ze te groot zijn.
Maar het laden van de images word er trager door, hoe kan ik dit oplossen. De images moet nog wel geresized worden.
function resize_image($image, $maxwidth=400, $maxheight=400) {
$size = getimagesize($image);
if($size[0] > $size[1]) {
if($size[0] > $maxwidth) {
$width = $maxwidth;
$tel = $width/$size[0]*$size[1];
$height= round($tel,0);
}
else {
$width = $size[0];
$height = $size[1];
}
}
else {
if($size[1] > $maxheight) {
$height = $maxheight;
$tel = $height/$size[1]*$size[0];
$width= round($tel,0);
}
else {
$width = $size[0];
$height = $size[1];
}
}
if($size[0] < $maxwidth && $size[1] < $maxheight) {
return '<img src='.$image.' width='.$width.' height='.$height.' />';
return '<a href="javascript:void(0)" onClick="window.open(\''.$image.'\', \'popup\', \'height='.$size[1].', width='.$size[0].', fullscreen=no, location=no, menubar=no, status=no, toolbar=no, scrollbars=no, resizable=no\')"><img style="border: 1px #ffffff dashed;" src='.$image.' width='.$width.' height='.$height.' title="Click here on the image for real size." /></a>';
}
}
function resize_image($image, $maxwidth=400, $maxheight=400) { if($size[0] > $size[1]) { if($size[0] > $maxwidth) { $width = $maxwidth; $tel = $width/$size[0]*$size[1]; } else { $width = $size[0]; $height = $size[1]; } } else { if($size[1] > $maxheight) { $height = $maxheight; $tel = $height/$size[1]*$size[0]; } else { $width = $size[0]; $height = $size[1]; } } if($size[0] < $maxwidth && $size[1] < $maxheight) { return '<img src='.$image.' width='.$width.' height='.$height.' />'; return '<a href="javascript:void(0)" onClick="window.open(\''.$image.'\', \'popup\', \'height='.$size[1].', width='.$size[0].', fullscreen=no, location=no, menubar=no, status=no, toolbar=no, scrollbars=no, resizable=no\')"><img style="border: 1px #ffffff dashed;" src='.$image.' width='.$width.' height='.$height.' title="Click here on the image for real size." /></a>'; } }
Mvg,
Thijs
|