This is my code for adding thumbs (adaptiveresize), feel free to response with better ways;
Row_Inserting
Code: Select all
if (isset($rsnew["afbeelding1"])) {
$path="../images/thumbs/";
$path.= $rsnew["afbeelding1"];
$this->afbeelding1->Upload->getTempThumb()->adaptiveResize(422, 316)->setOptions(array('jpegQuality' => 90))->save($path);
}
Row_Updating
Code: Select all
if (isset($rsnew["afbeelding1"])) {
$path="../images/thumbs/";
$path.= $rsnew["afbeelding1"];
$this->afbeelding1->Upload->getTempThumb()->adaptiveResize(422, 316)->setOptions(array('jpegQuality' => 90))->save($path);
}
$afbeelding1=$rsold['afbeelding1'];
@unlink("../images/thumbs/".$afbeelding1);
Row_Deleting
Code: Select all
$afbeelding1=$rs['afbeelding1'];
@unlink("../images/".$afbeelding1);
Now the thumb is deleted if row is deleted, and when the image is replaced with another image. But I'm searching for a way to also remove the thumb when the image is only removed and not the whole row.