Create thumb and deleted when row removed of image replaced

Tips submitted by PHPMaker users
Post Reply
brokenrules
User
Posts: 14

Create thumb and deleted when row removed of image replaced

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


brokenrules
User
Posts: 14

Post 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.)


Post Reply