Browse Source

Add catalog thumbnails for file placeholder, handle the first of multiple OP images being deleted

Thank you based lewdposter
main
discomrade 3 years ago
parent
commit
d3d3e2e969
  1. 53
      templates/themes/catalog/theme.php

53
templates/themes/catalog/theme.php

@ -191,6 +191,28 @@
return $sql;
}
private function filepathForThumb($thumb_or_special, $path_when_file) {
global $config;
if ($thumb_or_special === 'deleted') {
return $config['root'] . $config['image_deleted'];
} else if ($thumb_or_special === 'spoiler') {
return $config['root'] . $config['spoiler_image'];
} else if ($thumb_or_special === 'file') {
// see twig_extension_filter
$ext = mb_strtolower(mb_substr($path_when_file, mb_strrpos($path_when_file, '.') + 1));
$icons = $config['file_icons'];
// see templates/post/image.html
if (isset($icons[$ext])) {
return $config['root'] . sprintf($config['file_thumb'], $icons[$ext]);
} else {
return $config['root'] . sprintf($config['file_thumb'], $icons['default']);
}
} else {
return $config['uri_thumb'] . $thumb_or_special;
}
}
private function generateRecentPosts($threads) {
global $config, $board;
@ -210,28 +232,23 @@
if (isset($post['files']) && $post['files']) {
$files = json_decode($post['files']);
if ($files[0]) {
if ($files[0]->file == 'deleted') {
if (count($files) > 1) {
foreach ($files as $file) {
if (($file == $files[0]) || ($file->file == 'deleted'))
continue;
$post['file'] = $config['uri_thumb'] . $file->thumb;
}
if (empty($post['file']))
$post['file'] = $config['image_deleted'];
} else {
$post['file'] = $config['image_deleted'];
if (isset($files[0]) && $files[0]) {
$foundone = false;
foreach ($files as $file) {
if ($file->file != 'deleted') {
$post['file'] = $this->filepathForThumb($file->thumb, $file->file);
$foundone = true;
break;
}
} else if($files[0]->thumb == 'spoiler') {
$post['file'] = '/' . $config['spoiler_image'];
} else {
$post['file'] = $config['uri_thumb'] . $files[0]->thumb;
}
if (!$foundone) {
$post['file'] = $this->filepathForThumb('deleted', null);
}
} else {
$post['file'] = $this->filepathForThumb('deleted', null);
}
} else {
$post['file'] = $config['root'] . $config['image_deleted'];
$post['file'] = $this->filepathForThumb('deleted', null);
}
if (empty($post['image_count']))

Loading…
Cancel
Save