![]()
$list = new Liste (array ('name' => "images", 'parent' => $tpl_content)); ?>
foreach ($list as $content) { ?>
if ($content->editMode && $content['image'] && !$content['image small']) {
$sourceFile = $content->element ("image")->fileName ();
$targetFile = "$sourceFile.scale";
$imageSize = getimagesize ($sourceFile);
$source_w = $imageSize[0];
$source_h = $imageSize[1];
$size = getimagesize ($sourceFile);
if ($size[0] * $size[1] * $size['channels'] > 10000000) {
echo "The image is to big!";
} else {
// kleines Bild
$target_s = 100;
$target_w = $target_s * (($source_w > $source_h) ? 1 : ($source_w / $source_h));
$target_h = $target_s * (($source_h > $source_w) ? 1 : ($source_h / $source_w));
$source_id = imageCreateFromJPEG ($sourceFile);
$target_id = imagecreatetruecolor ($target_w, $target_h);
imagecopyresampled ($target_id, $source_id, 0, 0, 0, 0, $target_w, $target_h, $source_w, $source_h);
imagejpeg ($target_id, $targetFile, 70);
$content->setElementValue ("image small", "", file_get_contents ($targetFile));
unlink ($targetFile);
// Großansicht
$target_s = 600;
$target_w = $target_s * (($source_w > $source_h) ? 1 : ($source_w / $source_h));
$target_h = $target_s * (($source_h > $source_w) ? 1 : ($source_h / $source_w));
$source_id = imageCreateFromJPEG ($sourceFile);
$target_id = imagecreatetruecolor ($target_w, $target_h);
imagecopyresampled ($target_id, $source_id, 0, 0, 0, 0, $target_w, $target_h, $source_w, $source_h);
imagejpeg ($target_id, $targetFile, 70);
$content->setElementValue ("image", "", file_get_contents ($targetFile));
unlink ($targetFile);
}
}
?>
- =$content->edit("image")?>
">
} ?>