blob: 079f5b78383cbd7388a0e6624ace9df95d361622 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
<?php
namespace app\models;
//Import image magic (lazy load)
use imagick;
class ProfilePic extends \lithium\data\Model {
//Where we are going to store the files in mongoDB
protected $_meta = array('source' => 'fs.files');
//Overriding save to do the thumbnailing :)
public function save($entity, $data, array $options = array())
{
//Create a new imagemagick object from the uploaded file
$im = new Imagick($data['file']);
//Create a thumbnail of the file, then store it in the "thumbnail" object
$data['thumbnail'] = $im->thumbnailImage(200, null);
//Pass the changes off to the original save method.
return parent::save($entity, $data, $options);
}
}
?>
|