-
-
+$html = '';
+
+$html .= '
+
+
+
';
+
+ if(file_exists(PATH_UPLOADS_PROFILES.$username.'.png')) {
+ $html .= '

';
+ }
+ else {
+ $html .= '
'.$L->g('Profile picture').'
';
+ }
+
+$html .= '
+
+
+
+
-
- ';
+
+
'.$L->g('Upload image').'
+
'.$L->g('Drag and drop or click here').'
+
- $html .= '
- ';
+ notallowed: function(file, settings) {
+ alert("'.$L->g('Supported image file types').' "+settings.allow);
+ }
+ };
- echo $html;
+ UIkit.uploadSelect($("#bludit-profile-picture-file-select"), settings);
+ UIkit.uploadDrop($("#bludit-profile-picture-drag-drop"), settings);
+
+});
+
+';
+
+ echo $html.$script;
}
}
\ No newline at end of file
diff --git a/kernel/admin/views/edit-user.php b/kernel/admin/views/edit-user.php
index de550f9f..ac8d2a55 100644
--- a/kernel/admin/views/edit-user.php
+++ b/kernel/admin/views/edit-user.php
@@ -129,16 +129,8 @@ if( ($Login->role()==='admin') && ($_User->username()!='admin') ) {
HTML::formClose();
echo '
';
-echo '';
-echo '
';
-if(file_exists(PATH_UPLOADS_PROFILES.$_User->username().'.jpg')) {
- echo '
.'.jpg)
';
-}
-else {
- echo '
'.$L->g('Profile picture').'
';
-}
-echo '
';
+echo '
';
HTML::profileUploader($_User->username());
diff --git a/kernel/ajax/uploader.php b/kernel/ajax/uploader.php
index e8c5fe7a..dbb626e0 100644
--- a/kernel/ajax/uploader.php
+++ b/kernel/ajax/uploader.php
@@ -38,10 +38,10 @@ if($type=='profilePicture')
{
// Resize and crop profile image.
$username = Sanitize::html($_POST['username']);
- $tmpName = $username.'.jpg';
+ $tmpName = $username.'.png';
$Image = new Image();
- $Image->setImage(PATH_TMP.'original'.'.'.$fileExtension, '200', '200', 'crop');
- $Image->saveImage(PATH_UPLOADS_PROFILES.$tmpName, 100, true);
+ $Image->setImage(PATH_TMP.'original'.'.'.$fileExtension, '400', '400', 'crop');
+ $Image->saveImage(PATH_UPLOADS_PROFILES.$tmpName, 100, false, true);
}
// --- OTHERS ---
else {
diff --git a/kernel/helpers/image.class.php b/kernel/helpers/image.class.php
index b9db4d38..db70ae74 100644
--- a/kernel/helpers/image.class.php
+++ b/kernel/helpers/image.class.php
@@ -19,7 +19,7 @@ class Image {
$this->resizeImage($newWidth, $newHeight, $option);
}
- public function saveImage($savePath, $imageQuality="100", $forceJPG=false)
+ public function saveImage($savePath, $imageQuality="100", $forceJPG=false, $forcePNG=false)
{
$extension = strtolower(pathinfo($savePath, PATHINFO_EXTENSION));
@@ -28,42 +28,46 @@ class Image {
$path_complete = $filename.'.'.$extension;
- if($forceJPG) {
- imagejpeg($this->imageResized, $filename.'.jpg', $imageQuality);
+ if($forcePNG) {
+ $extension = 'png';
}
- else
+ elseif($forceJPG) {
+ $extension = 'jpg';
+ }
+
+ switch($extension)
{
- switch($extension)
- {
- case 'jpg':
- case 'jpeg':
- if (imagetypes() & IMG_JPG) {
- imagejpeg($this->imageResized, $path_complete, $imageQuality);
- }
- break;
+ case 'jpg':
+ case 'jpeg':
+ // Checking for JPG support
+ if (imagetypes() & IMG_JPG) {
+ imagejpeg($this->imageResized, $path_complete, $imageQuality);
+ }
+ break;
- case 'gif':
- if (imagetypes() & IMG_GIF) {
- imagegif($this->imageResized, $path_complete);
- }
- break;
+ case 'gif':
+ // Checking for GIF support
+ if (imagetypes() & IMG_GIF) {
+ imagegif($this->imageResized, $path_complete);
+ }
+ break;
- case 'png':
- // *** Scale quality from 0-100 to 0-9
- $scaleQuality = round(($imageQuality/100) * 9);
+ case 'png':
+ // *** Scale quality from 0-100 to 0-9
+ $scaleQuality = round(($imageQuality/100) * 9);
- // *** Invert quality setting as 0 is best, not 9
- $invertScaleQuality = 9 - $scaleQuality;
+ // *** Invert quality setting as 0 is best, not 9
+ $invertScaleQuality = 9 - $scaleQuality;
- if (imagetypes() & IMG_PNG) {
- imagepng($this->imageResized, $path_complete, $invertScaleQuality);
- }
- break;
+ // Checking for PNG support
+ if (imagetypes() & IMG_PNG) {
+ imagepng($this->imageResized, $path_complete, $invertScaleQuality);
+ }
+ break;
- default:
- // *** No extension - No save.
- break;
- }
+ default:
+ // Fail extension detection
+ break;
}
imagedestroy($this->imageResized);
diff --git a/kernel/user.class.php b/kernel/user.class.php
index 0b80c92a..f75456ca 100644
--- a/kernel/user.class.php
+++ b/kernel/user.class.php
@@ -81,4 +81,15 @@ class User
return $this->getField('instagramUsername');
}
+ public function profilePicture($absolute=true)
+ {
+ $filename = $this->getField('username').'.png';
+
+ if($absolute) {
+ return HTML_PATH_UPLOADS_PROFILES.$filename;
+ }
+
+ return $filename;
+ }
+
}
\ No newline at end of file