diff --git a/kernel/admin/themes/default/init.php b/kernel/admin/themes/default/init.php index af9bff04..236ac611 100644 --- a/kernel/admin/themes/default/init.php +++ b/kernel/admin/themes/default/init.php @@ -248,8 +248,8 @@ class HTML { allcomplete: function(response) { bar.css("width", "100%").text("100%"); - setTimeout(function() { progressbar.addClass("uk-hidden"); }, 250); - $("#jsimageList").prepend(""); + progressbar.addClass("uk-hidden"); + $("#jsprofilePicture").attr("src", "'.HTML_PATH_UPLOADS_PROFILES.$username.'.jpg?"+new Date().getTime()); }, notallowed: function(file, settings) { diff --git a/kernel/ajax/uploader.php b/kernel/ajax/uploader.php index d1956fb5..8f379e1d 100644 --- a/kernel/ajax/uploader.php +++ b/kernel/ajax/uploader.php @@ -29,12 +29,19 @@ if(empty($tmpName)) { $tmpName = $filename.'.'.$fileExtension; } +// --- PROFILE PICTURE --- if($type=='profilePicture') { $username = Sanitize::html($_POST['username']); $tmpName = $username.'.jpg'; move_uploaded_file($source, PATH_UPLOADS_PROFILES.$tmpName); + + // Resize and crop profile image. + $Image = new Image(); + $Image->setImage(PATH_UPLOADS_PROFILES.$tmpName, '200', '200', 'crop'); + $Image->saveImage(PATH_UPLOADS_PROFILES.$tmpName, 100, true); } +// --- OTHERS --- else { move_uploaded_file($source, PATH_UPLOADS.$tmpName); } diff --git a/kernel/helpers/image.class.php b/kernel/helpers/image.class.php index 1ee2453e..b9db4d38 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", $force_jpg=false) + public function saveImage($savePath, $imageQuality="100", $forceJPG=false) { $extension = strtolower(pathinfo($savePath, PATHINFO_EXTENSION)); @@ -28,8 +28,7 @@ class Image { $path_complete = $filename.'.'.$extension; - if($force_jpg) - { + if($forceJPG) { imagejpeg($this->imageResized, $filename.'.jpg', $imageQuality); } else diff --git a/kernel/post.class.php b/kernel/post.class.php index 3abed452..83fe8143 100644 --- a/kernel/post.class.php +++ b/kernel/post.class.php @@ -83,6 +83,11 @@ class Post extends fileContent return $this->getField('username'); } + public function profilePicture() + { + return HTML_PATH_UPLOADS_PROFILES.$this->username().'.jpg'; + } + public function authorFirstName() { return $this->getField('authorFirstName');