idleman 5 éve
szülő
commit
6b35204945

+ 7 - 9
plugin/hackpoint/action.php

@@ -77,21 +77,19 @@ switch($_['action']){
 		global $myUser,$_;
 		
 		require_once(__DIR__.SLASH.'Sketch.class.php');
-
+		if(!is_numeric($_['sketch'])) throw new Exception("Sketch non spécifié", 400);
 		$sketch = Sketch::provide('sketch');
-		if($myUser->login!=$sketch->creator) throw new Exception("Pemrission insuffisantes", 403);
+		if($myUser->login!= $sketch->creator) throw new Exception("Permission insuffisantes", 403);
 		
 		$folder = $sketch->directory();
-
 		if(!file_exists($folder)) mkdir($folder,0755,true);
-
-		
 		$name = 'cover.jpg';
 
-		$stream = preg_replace('|data\:image/[^;];base64,|is','',$_['stream']);
-
-		$row = file_put_contents($folder.SLASH.$name, base64_decode($stream));
-		
+		$stream = preg_replace('|data\:image\/[^;]*;base64,|is','',$_['stream']);
+		$filepath = $folder.SLASH.$name;
+		$row = file_put_contents($filepath, base64_decode($stream));
+		Image::resize($filepath,150,150);
+		$response['stream'] = 'data:image/jpg;base64,'.base64_encode(file_get_contents($filepath));
 		
 	});
 	break;

+ 1 - 1
plugin/hackpoint/css/main.css

@@ -28,7 +28,7 @@
 }
 
 #sketchs .card-img-top {
-    max-width: 150px;
+    max-height: 180px;
     width: 100%;
     border-top-left-radius: calc(.25rem - 1px);
     border-top-right-radius: calc(.25rem - 1px);

+ 3 - 3
plugin/hackpoint/js/main.js

@@ -314,9 +314,9 @@ function hackpoint_sketch_save_cover(input,stream){
 	$.action({
 			action : 'hackpoint_sketch_save_cover',
 			stream : stream,
-			skecth : li.attr('data-id')
-	},function(){
-		
+			sketch : li.attr('data-id')
+	},function(r){
+		input.attr('src',r.stream);
 	});
 }