Create thumb and deleted when row removed of image replaced

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

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

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.


brokenrules
User
Posts: 13

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