summaryrefslogtreecommitdiffstats
path: root/models/ProfilePic.php
diff options
context:
space:
mode:
authorMichael Francis <edude03@gmail.com>2011-05-28 13:28:16 -0400
committerMichael Francis <edude03@gmail.com>2011-05-28 13:28:16 -0400
commit2389d66da849798f8d4ec5f10e3b07c11da49185 (patch)
treee22556d12982395b469a23420c662662e3e064cc /models/ProfilePic.php
downloadotakuhub-2389d66da849798f8d4ec5f10e3b07c11da49185.tar.xz
Initial Commit
Diffstat (limited to 'models/ProfilePic.php')
-rw-r--r--models/ProfilePic.php28
1 files changed, 28 insertions, 0 deletions
diff --git a/models/ProfilePic.php b/models/ProfilePic.php
new file mode 100644
index 0000000..079f5b7
--- /dev/null
+++ b/models/ProfilePic.php
@@ -0,0 +1,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);
+ }
+}
+
+?> \ No newline at end of file