Merge pull request #328 from alexandreteles/patch-2

Added SVG image support for uploads
This commit is contained in:
Diego Najar 2016-08-22 21:13:32 +02:00 committed by GitHub
commit 2e71042286
2 changed files with 13 additions and 4 deletions

View File

@ -356,7 +356,7 @@ $(document).ready(function() {
{ {
type: "json", type: "json",
action: HTML_PATH_ADMIN_ROOT+"ajax/uploader", action: HTML_PATH_ADMIN_ROOT+"ajax/uploader",
allow : "*.(jpg|jpeg|gif|png)", allow : "*.(jpg|jpeg|gif|png|svg)",
params: {"type":"profilePicture", "username":"'.$username.'"}, params: {"type":"profilePicture", "username":"'.$username.'"},
loadstart: function() { loadstart: function() {
@ -391,4 +391,4 @@ $(document).ready(function() {
echo $html.$script; echo $html.$script;
} }
} }

View File

@ -47,11 +47,20 @@ if($type=='profilePicture')
else { else {
// Generate the thumbnail // Generate the thumbnail
$Image = new Image(); $Image = new Image();
$Image->setImage(PATH_TMP.'original'.'.'.$fileExtension, THUMBNAILS_WIDTH, THUMBNAILS_HEIGHT, 'crop');
$Image->saveImage(PATH_UPLOADS_THUMBNAILS.$tmpName, THUMBNAILS_QUALITY, true); //Handling all other formats than svg
if (strcasecmp($fileExtension, 'svg') != 0) {
$Image->setImage(PATH_TMP.'original'.'.'.$fileExtension, THUMBNAILS_WIDTH, THUMBNAILS_HEIGHT, 'crop');
$Image->saveImage(PATH_UPLOADS_THUMBNAILS.$tmpName, THUMBNAILS_QUALITY, true);
}
// Move the original to the upload folder. // Move the original to the upload folder.
rename(PATH_TMP.'original'.'.'.$fileExtension, PATH_UPLOADS.$tmpName); rename(PATH_TMP.'original'.'.'.$fileExtension, PATH_UPLOADS.$tmpName);
//If it is a svg file, just save a copy in thumbnail-folder
if (strcasecmp($fileExtension, 'svg') == 0) {
symlink(PATH_UPLOADS.$tmpName, PATH_UPLOADS_THUMBNAILS.$tmpName);
}
} }
// Remove the Bludit temporary file. // Remove the Bludit temporary file.