Commit 0f93c048 authored by Richard Mansfield's avatar Richard Mansfield

Detect images on upload

parent 976b32d9
......@@ -285,9 +285,8 @@ class ArtefactTypeFile extends ArtefactTypeFileBase {
* Test file type and return a new Image or File.
*/
public static function new_file($path, $data) {
//require_once('file.php');
//$type = get_mime_type($path);
$type = 'foo';
require_once('file.php');
$type = get_mime_type($path);
if (ArtefactTypeImage::is_image_mime_type($type)) {
return new ArtefactTypeImage(0, $data);
}
......@@ -502,7 +501,8 @@ class ArtefactTypeImage extends ArtefactTypeFile {
}
public static function is_image_mime_type($type) {
return in_array($type, array('image/jpeg', 'image/jpg', 'image/gif', 'image/png'));
require_once('file.php');
return is_image_mime_type($type);
}
}
......
......@@ -500,6 +500,12 @@ function get_mime_type($file) {
}
function is_image_mime_type($type) {
return in_array($type, array('image/jpeg', 'image/jpg', 'image/gif', 'image/png'));
}
/**
* Given a path under dataroot, an ID and a size, return the path to a file
* matching all criteria.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment