Browse Source

improve image show

master
filesite 2 years ago
parent
commit
2577828e15
  1. 2
      themes/googleimage/views/layout/main.php
  2. 33
      themes/googleimage/views/site/index.php

2
themes/googleimage/views/layout/main.php

@ -25,7 +25,7 @@ require_once __DIR__ . '/../../../../plugins/Html.php'; @@ -25,7 +25,7 @@ require_once __DIR__ . '/../../../../plugins/Html.php';
<div class="header">
<a href="/" class="logo">
<img src="/content/machete_icon.png" alt="Logo of FileSite.io" height="34">
<img src="/content/machete_icon.png" alt="Logo of FileSite.io" width="34" height="34">
FileSite.io
</a>
<a href="#modal_about" role="button" class="about btn-open">

33
themes/googleimage/views/site/index.php

@ -60,15 +60,22 @@ eof; @@ -60,15 +60,22 @@ eof;
}
if (!empty($category['directories'])) { //两级目录支持
$index = 0;
foreach($category['directories'] as $dir) {
echo <<<eof
<a href="{$dir['path']}" class="img-item">
eof;
if (!empty($dir['snapshot'])) {
echo <<<eof
if ($index > 0) {
echo <<<eof
<img data-src="{$dir['snapshot']}" class="lazyload" alt="{$dir['directory']}">
eof;
}else {
echo <<<eof
<img src="{$dir['snapshot']}" alt="{$dir['directory']}">
eof;
}
}else if (!empty($dir['files'])) {
$first_img = array_shift($dir['files']);
if (!in_array($first_img['extension'], $imgExts)) {
@ -81,9 +88,15 @@ eof; @@ -81,9 +88,15 @@ eof;
}
if (in_array($first_img['extension'], $imgExts)) {
echo <<<eof
if ($index > 0) {
echo <<<eof
<img data-src="{$first_img['path']}" class="lazyload" alt="{$first_img['filename']}">
eof;
}else {
echo <<<eof
<img src="{$first_img['path']}" alt="{$first_img['filename']}">
eof;
}
}else {
echo <<<eof
<img src="/img/default.png" alt="default image">
@ -96,20 +109,34 @@ eof; @@ -96,20 +109,34 @@ eof;
<strong>{$title}</strong>
</a>
eof;
$index ++;
}
}
if (!empty($category['files'])) { //一级目录支持
$index = 0;
foreach($category['files'] as $file) {
if (!in_array($file['extension'], $imgExts)) {continue;}
$title = !empty($file['title']) ? $file['title'] : $file['filename'];
echo <<<eof
if ($index > 0) {
echo <<<eof
<a href="{$file['path']}" class="img-item img-preview" target="_blank">
<img data-src="{$file['path']}" class="lazyload" alt="{$file['filename']}">
<strong>{$title}</strong>
</a>
eof;
}else {
echo <<<eof
<a href="{$file['path']}" class="img-item img-preview" target="_blank">
<img src="{$file['path']}" alt="{$file['filename']}">
<strong>{$title}</strong>
</a>
eof;
}
$index ++;
}
}
?>

Loading…
Cancel
Save