Page 1 of 1

Create thumb and deleted when row removed of image replaced

Posted: Fri Dec 03, 2021 11:50 pm
by brokenrules

This is my code for adding thumbs (adaptiveresize), feel free to response with better ways;

Row_Inserting

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

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

$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.


Re: Create thumb and deleted when row removed of image replaced

Posted: Tue Jan 25, 2022 5:00 pm
by brokenrules

Is there a way to also remove the thumb when the image is only removed and not the whole row.
(Now the thumb is deleted only if row is deleted, and when the image is replaced with another image.)