-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathimages-download-tpl.php
87 lines (84 loc) · 2.29 KB
/
images-download-tpl.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<!DOCTYPE html>
<html>
<head>
<style>
div#content {
-webkit-column-count: 3;
max-width: 1100px;
margin: 50px auto;
}
figure {
width:92%;
background: #fefefe;
border: 2px solid #fcfcfc;
box-shadow: 0 1px 2px rgba(34, 25, 25, 0.4);
margin: 0 2px 15px 0;
padding: 10px;
transition: opacity .4s ease-in-out;
-webkit-column-break-inside: avoid;
display: inline-block;
}
figure img {
width: 100%;
height: auto;
padding-bottom: 15px;
margin-bottom: 5px;
}
figure figcaption {
text-align: center;
overflow: hidden;
}
figcaption a {
text-decoration: none;
color: darkslateblue;
}
button {
position: fixed;
right: 50px;
bottom: 35px;
background-color: white;
color: darkslateblue;
border: none;
font-size:1.5em;
font-weight:bold;
cursor: hand;
}
button:hover{
color: black;
}
</style>
</head>
<body>
<div id="content">
<?php
/** @var array $imageUrls */
foreach ($imageUrls as $url) {
$fileName = basename($url);
echo <<<EOD
<figure>
<a href="$url" download="$fileName" title="Use Google Chrome browser if any trouble happened.">
<img src="$url">
</a>
<figcaption>
<a href="$url" download="$fileName" class="downA" title="Use Google Chrome browser if any trouble happened.">Download</a>
</figcaption>
</figure>
EOD;
}
?>
</div>
<button id="downButton" title="Only tested on Google Chrome, switch to Google Chrome browser if any trouble happened.">Download All</button>
<script>
var button = document.getElementById('downButton');
button.onclick = function () {
var downATags = document.querySelectorAll('a.downA');
var i = 0;
do
downATags[i].click();
while (i++ < downATags.length);
};
button.style.display = 'none';
window.onload = function () { button.style.display = 'block'; };
</script>
</body>
</html>