This repository was archived by the owner on Jan 29, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 68
This repository was archived by the owner on Jan 29, 2021. It is now read-only.
Tranformed images are not deleted automatically #189
Copy link
Copy link
Open
Description
Hi,
first, great job!!
I have a problem! If I delete a database record, only the original imge are deleted.
The transformed images are not deleted!
What must I do to make it work?
<?php
App::uses('AppModel', 'Model');
define('ADVER_IMAGE_DIR', '/files/advertisements/');
define('ADVER_ORIGINAL_DIR', ADVER_IMAGE_DIR . '/originals/');
define('ADVER_UPLOAD_ORIGINAL_DIR', WWW_ROOT . ADVER_ORIGINAL_DIR);
define('ADVER_THUMBNAIL_DIR', ADVER_IMAGE_DIR . '/thumbs/');
define('ADVER_UPLOAD_THUMBNAIL_DIR', WWW_ROOT . ADVER_THUMBNAIL_DIR);
/**
* Advertisement Model
*
*/
class Advertisement extends AppModel {
public $actsAs = array(
'Uploader.FileValidation' => array(
'image' => array(
'maxWidth' => 1920,
'minHeight' => 1080,
'extension' => array('gif', 'jpg', 'png', 'jpeg'),
'type' => 'image',
'mimeType' => array('image/gif', 'image/jpeg', 'image/png'),
'filesize' => 5242880,
'required' => true
)
),
'Uploader.Attachment' => array(
'image' => array(
'nameCallback' => 'imageName',
'tempDir' => TMP,
'finalPath' => ADVER_ORIGINAL_DIR,
'uploadDir' => ADVER_UPLOAD_ORIGINAL_DIR,
'overwrite' => true,
'stopSave' => true,
'allowEmpty' => true,
'metaColumns' => array(
'ext' => 'extension',
'basename' => 'basename',
'type' => 'type',
'size' => 'size',
'exif.model' => 'camera',
'exif.make' => 'make',
),
'transforms' => array(
'imageSmall' => array(
'nameCallback' => 'imageName',
'class' => 'crop',
'append' => '-small',
'overwrite' => true,
'self' => false,
'width' => 100,
'height' => 100,
'finalPath' => ADVER_THUMBNAIL_DIR,
'uploadDir' => ADVER_UPLOAD_THUMBNAIL_DIR
),
'imageMedium' => array(
'nameCallback' => 'imageName',
'class' => 'resize',
'append' => '-medium',
'width' => 800,
'height' => 600,
'aspect' => false,
'finalPath' => ADVER_THUMBNAIL_DIR,
'uploadDir' => ADVER_UPLOAD_THUMBNAIL_DIR
),
'imageLarge' => array(
'nameCallback' => 'imageName',
'class' => 'resize',
'append' => '-large',
'width' => 1920,
'height' => 1080,
'aspect' => false,
'finalPath' => ADVER_THUMBNAIL_DIR,
'uploadDir' => ADVER_UPLOAD_THUMBNAIL_DIR
)
)
)
)
);
public function imageName($name, $file) {
return $this->getUploadedFile()->name();
}
}
Metadata
Metadata
Assignees
Labels
No labels