From 58d378fe46787c7155a19dc72edff5bb57cdf7a9 Mon Sep 17 00:00:00 2001 From: Trevor Slocum Date: Tue, 14 May 2013 20:42:56 -0700 Subject: [PATCH] Add TINYIB_MAXWOP and TINYIB_MAXHOP which specify thumbnail sizes only for new threads --- imgboard.php | 2 +- inc/defines.php | 2 ++ inc/functions.php | 11 +++++++++-- inc/html.php | 9 ++++++--- settings.default.php | 6 ++++-- 5 files changed, 22 insertions(+), 8 deletions(-) diff --git a/imgboard.php b/imgboard.php index 94ae2fd..e0257be 100644 --- a/imgboard.php +++ b/imgboard.php @@ -126,7 +126,7 @@ if (isset($_POST['message']) || isset($_POST['file'])) { $post['image_width'] = $file_info[0]; $post['image_height'] = $file_info[1]; - list($thumb_maxwidth, $thumb_maxheight) = thumbnailDimensions($post['image_width'], $post['image_height']); + list($thumb_maxwidth, $thumb_maxheight) = thumbnailDimensions($post); if (!createThumbnail($file_location, $thumb_location, $thumb_maxwidth, $thumb_maxheight)) { fancyDie("Could not create thumbnail."); diff --git a/inc/defines.php b/inc/defines.php index 3478041..12c99af 100644 --- a/inc/defines.php +++ b/inc/defines.php @@ -8,4 +8,6 @@ define('TINYIB_RESPAGE', true); // The following are provided for backward compatibility and should not be relied upon // Copy new settings from settings.default.php to settings.php if (!defined('TINYIB_MAXREPLIES')) { define('TINYIB_MAXREPLIES', 0); } +if (!defined('TINYIB_MAXWOP')) { define('TINYIB_MAXWOP', TINYIB_MAXW); } +if (!defined('TINYIB_MAXHOP')) { define('TINYIB_MAXHOP', TINYIB_MAXH); } ?> \ No newline at end of file diff --git a/inc/functions.php b/inc/functions.php index 02b0c1d..f0cb8f8 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -282,8 +282,15 @@ function checkDuplicateImage($hex) { } } -function thumbnailDimensions($width, $height) { - return ($width > TINYIB_MAXW || $height > TINYIB_MAXH) ? array(TINYIB_MAXW, TINYIB_MAXH) : array($width, $height); +function thumbnailDimensions($post) { + if ($post['parent'] == TINYIB_NEWTHREAD) { + $max_width = TINYIB_MAXWOP; + $max_height = TINYIB_MAXHOP; + } else { + $max_width = TINYIB_MAXW; + $max_height = TINYIB_MAXH; + } + return ($post['image_width'] > $max_width || $post['image_height'] > $max_height) ? array($max_width, $max_height) : array($post['image_width'], $post['image_height']); } function createThumbnail($name, $filename, $new_w, $new_h) { diff --git a/inc/html.php b/inc/html.php index 1e6f512..ce946e6 100644 --- a/inc/html.php +++ b/inc/html.php @@ -121,7 +121,10 @@ EOF; function buildPage($htmlposts, $parent, $pages=0, $thispage=0) { $managelink = basename($_SERVER['PHP_SELF']) . "?manage"; - $maxdimensions = TINYIB_MAXW . 'x' . TINYIB_MAXH; + $maxdimensions = TINYIB_MAXWOP . 'x' . TINYIB_MAXHOP; + if (TINYIB_MAXW != TINYIB_MAXWOP || TINYIB_MAXH != TINYIB_MAXHOP) { + $maxdimensions .= ' (new thread) or ' . TINYIB_MAXW . 'x' . TINYIB_MAXH . ' (reply)'; + } $maxfilesize = TINYIB_MAXKB * 1024; $postingmode = ""; @@ -239,9 +242,9 @@ EOF; diff --git a/settings.default.php b/settings.default.php index 89791a1..f7ed792 100644 --- a/settings.default.php +++ b/settings.default.php @@ -8,8 +8,10 @@ define('TINYIB_PREVIEWREPLIES', 3); // Amount of replies previewed on index page define('TINYIB_MAXREPLIES', 0); // Maximum replies before a thread stops bumping [0 to disable] define('TINYIB_MAXKB', 2048); // Maximum file size in kilobytes [0 to disable] define('TINYIB_MAXKBDESC', "2 MB"); // Human-readable representation of the maximum file size -define('TINYIB_MAXW', 250); // Maximum image width -define('TINYIB_MAXH', 250); // Maximum image height - Images exceeding these sizes will be thumbnailed +define('TINYIB_MAXW', 250); // Maximum image width (reply) - Images exceeding these sizes will be thumbnailed +define('TINYIB_MAXH', 250); // Maximum image height (reply) +define('TINYIB_MAXWOP', 250); // Maximum image width (new thread) +define('TINYIB_MAXHOP', 250); // Maximum image height (new thread) define('TINYIB_DELAY', 30); // Delay between posts to help control flooding [0 to disable] define('TINYIB_LOGO', ""); // Logo HTML define('TINYIB_TRIPSEED', ""); // Enter some random text - Used when generating secure tripcodes - Must not change once set