Improve image thumbnail
And auto download apk for android
This commit is contained in:
parent
673f0433ed
commit
0f2f5172ac
@ -1,9 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
$ua = strtolower($_SERVER['HTTP_USER_AGENT']);
|
||||||
|
if(stripos($ua,'android') !== false): // && stripos($ua,'mobile') !== false) {
|
||||||
|
$file = "localTransfer-app.apk";
|
||||||
|
|
||||||
|
header("Content-Description: File Transfer");
|
||||||
|
header("Content-Type: application/octet-stream");
|
||||||
|
header("Content-Disposition: attachment; filename=\"". basename($file) ."\"");
|
||||||
|
|
||||||
|
readfile ($file);
|
||||||
|
//header("Location: ".$_SERVER['REQUEST_URI'].$file);
|
||||||
|
exit();
|
||||||
|
else:
|
||||||
|
?>
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang="fr">
|
<html lang="fr">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<link href="style/style.css" rel="stylesheet">
|
<link href="style/style.css" rel="stylesheet">
|
||||||
<link rel="stylesheet" href="style/imagepreview.min.css"/>
|
<link rel="stylesheet" href="style/imagepreview.css"/>
|
||||||
<link href="/fontawesome/css/all.css" rel="stylesheet" />
|
<link href="/fontawesome/css/all.css" rel="stylesheet" />
|
||||||
<title>Local Transfer</title>
|
<title>Local Transfer</title>
|
||||||
</head>
|
</head>
|
||||||
@ -32,7 +46,10 @@
|
|||||||
<div id="transProgress"></div>
|
<div id="transProgress"></div>
|
||||||
|
|
||||||
<script src="js/jquery-3.5.1.min.js" type="text/javascript"></script>
|
<script src="js/jquery-3.5.1.min.js" type="text/javascript"></script>
|
||||||
<script src="js/imagepreview.min.js" type="text/javascript"></script>
|
<script src="js/imagepreview.js" type="text/javascript"></script>
|
||||||
<script src="js/script.js"></script>
|
<script src="js/script.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
<?php
|
||||||
|
endif;
|
||||||
|
?>
|
52
js/imagepreview.js
Normal file
52
js/imagepreview.js
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
!(function (a) {
|
||||||
|
"use strict";
|
||||||
|
a.fn.anarchytip = function (b) {
|
||||||
|
var c = a.extend({ xOffset: 10, yOffset: 30 }, b);
|
||||||
|
return this.each(function () {
|
||||||
|
var b = a(this);
|
||||||
|
b.hover(
|
||||||
|
function (b) {
|
||||||
|
(this.t = this.title), (this.title = "");
|
||||||
|
var d = "" != this.t ? "<br/>" + this.t : "";
|
||||||
|
a("body").append("<p id='preview'><img src='' alt='Image preview' />" + d + "</p>"),
|
||||||
|
a("#preview")
|
||||||
|
.css({ top: b.pageY - c.xOffset + "px", left: b.pageX + c.yOffset + "px" })
|
||||||
|
.fadeIn();
|
||||||
|
downloadThumbnail(this.pathname);
|
||||||
|
},
|
||||||
|
function () {
|
||||||
|
(this.title = this.t), a("#preview").remove();
|
||||||
|
}
|
||||||
|
),
|
||||||
|
b.mousemove(function (b) {
|
||||||
|
a("#preview")
|
||||||
|
.css("top", b.pageY - c.xOffset + "px")
|
||||||
|
.css("left", b.pageX + c.yOffset + "px");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
})(jQuery);
|
||||||
|
|
||||||
|
function downloadThumbnail(file) {
|
||||||
|
var href = 'thumbnail.php'
|
||||||
|
var blobUrl;
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: href,
|
||||||
|
data: {
|
||||||
|
"file": file,
|
||||||
|
"size": '200'
|
||||||
|
},
|
||||||
|
xhrFields:{
|
||||||
|
responseType: 'blob'
|
||||||
|
},
|
||||||
|
success: function(data){
|
||||||
|
var blob = data;
|
||||||
|
blobUrl = window.URL.createObjectURL(new Blob([blob], {type: blob.type}));
|
||||||
|
console.log(blobUrl);
|
||||||
|
$('#preview img').attr('src', blobUrl);
|
||||||
|
},
|
||||||
|
error: error,
|
||||||
|
dataType: 'binary'
|
||||||
|
});
|
||||||
|
};
|
63
style/imagepreview.css
Normal file
63
style/imagepreview.css
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
padding: 40px;
|
||||||
|
background: #fff;
|
||||||
|
font: 80% Arial, Helvetica, sans-serif;
|
||||||
|
color: #555;
|
||||||
|
line-height: 180%;
|
||||||
|
}
|
||||||
|
h1 {
|
||||||
|
font-size: 180%;
|
||||||
|
font-weight: 400;
|
||||||
|
color: #555;
|
||||||
|
}
|
||||||
|
h2 {
|
||||||
|
clear: both;
|
||||||
|
font-size: 160%;
|
||||||
|
font-weight: 400;
|
||||||
|
color: #555;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0.5em 0;
|
||||||
|
}
|
||||||
|
a {
|
||||||
|
text-decoration: none;
|
||||||
|
color: #f30;
|
||||||
|
}
|
||||||
|
p {
|
||||||
|
clear: both;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0.5em 0;
|
||||||
|
}
|
||||||
|
pre {
|
||||||
|
display: block;
|
||||||
|
font: 100% "Courier New", Courier, monospace;
|
||||||
|
padding: 10px;
|
||||||
|
border: 1px solid #bae2f0;
|
||||||
|
background: #e3f4f9;
|
||||||
|
margin: 0.5em 0;
|
||||||
|
overflow: auto;
|
||||||
|
width: 800px;
|
||||||
|
}
|
||||||
|
img {
|
||||||
|
border: none;
|
||||||
|
max-width: 300px;
|
||||||
|
}
|
||||||
|
ul,
|
||||||
|
li {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
li {
|
||||||
|
list-style: none;
|
||||||
|
float: left;
|
||||||
|
display: inline;
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
#preview {
|
||||||
|
position: absolute;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
background: #333;
|
||||||
|
padding: 5px;
|
||||||
|
display: none;
|
||||||
|
color: #fff;
|
||||||
|
}
|
46
thumbnail.php
Normal file
46
thumbnail.php
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
ini_set('display_errors', TRUE);
|
||||||
|
ini_set('display_startup_errors', TRUE);
|
||||||
|
|
||||||
|
$root = $_SERVER["DOCUMENT_ROOT"];
|
||||||
|
|
||||||
|
$directory = "/uploads/";
|
||||||
|
|
||||||
|
if(isset($_GET["file"])) {
|
||||||
|
$file = $root.urldecode($_GET["file"]);
|
||||||
|
$size = isset($_GET["size"]) ? $_GET["size"] : 100;
|
||||||
|
if(file_exists($file)) {
|
||||||
|
echo getthumbnail($file, $size);
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
header("HTTP/1.1 400 File not Found");
|
||||||
|
echo $file." not Found";
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function getthumbnail(string $file, int $size)
|
||||||
|
{
|
||||||
|
|
||||||
|
list($width, $height) = getimagesize($file);
|
||||||
|
|
||||||
|
// Create an Imagick object
|
||||||
|
$imagick = new Imagick($file);
|
||||||
|
|
||||||
|
// Function to set the background color
|
||||||
|
$imagick->setbackgroundcolor('rgb(0, 0, 0)');
|
||||||
|
|
||||||
|
// Use thumbnailImage function
|
||||||
|
$imagick->thumbnailImage($width*$size/$height, $size, true, true);
|
||||||
|
header("Content-Type: image/jpg");
|
||||||
|
|
||||||
|
// Display the output image
|
||||||
|
echo $imagick->getImageBlob();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
Loading…
x
Reference in New Issue
Block a user