From a25e5f7839fa68fe464bbb0d5fe112b9d13a3c76 Mon Sep 17 00:00:00 2001 From: czaks Date: Wed, 24 Sep 2014 03:21:32 +0200 Subject: [PATCH] additional measurements for catalog, so it does not throw errors; should fix vichan-devel#84 --- templates/themes/catalog/theme.php | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/templates/themes/catalog/theme.php b/templates/themes/catalog/theme.php index 357870e4..9ba2d27a 100644 --- a/templates/themes/catalog/theme.php +++ b/templates/themes/catalog/theme.php @@ -49,28 +49,30 @@ $post['youtube'] = $matches[2]; } - if (isset($post['files'])) { + if (isset($post['files']) && $post['files']) { $files = json_decode($post['files']); - 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 ($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']; + if (empty($post['file'])) $post['file'] = $config['image_deleted']; + } + else { + $post['file'] = $config['image_deleted']; + } + } + else if($files[0]->thumb == 'spoiler') { + $post['file'] = '/' . $config['spoiler_image']; } else { - $post['file'] = $config['image_deleted']; + $post['file'] = $config['uri_thumb'] . $files[0]->thumb; } } - else if($files[0]->thumb == 'spoiler') { - $post['file'] = '/' . $config['spoiler_image']; - } - else { - $post['file'] = $config['uri_thumb'] . $files[0]->thumb; - } } if (empty($post['image_count'])) $post['image_count'] = 0;