Browse Source

improve image show

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

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

@ -25,7 +25,7 @@ require_once __DIR__ . '/../../../../plugins/Html.php';
<div class="header"> <div class="header">
<a href="/" class="logo"> <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 FileSite.io
</a> </a>
<a href="#modal_about" role="button" class="about btn-open"> <a href="#modal_about" role="button" class="about btn-open">

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

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