Browse Source

image spoilers

pull/40/head
Savetheinternet 13 years ago
parent
commit
53dce652a8
  1. 8
      inc/config.php
  2. 18
      inc/display.php
  3. 19
      post.php
  4. 2
      templates/index.html
  5. 2
      templates/thread.html

8
inc/config.php

@ -195,7 +195,8 @@
'raw', 'raw',
'embed', 'embed',
'recaptcha_challenge_field', 'recaptcha_challenge_field',
'recaptcha_response_field' 'recaptcha_response_field',
'spoiler'
); );
// Custom flood filters. Detect flood attacks and reject new posts if there's a positive match. // Custom flood filters. Detect flood attacks and reject new posts if there's a positive match.
@ -301,6 +302,9 @@
// $config['custom_tripcode']['#test123'] = '!HelloWorld'; // $config['custom_tripcode']['#test123'] = '!HelloWorld';
// $config['custom_tripcode']['##securetrip'] = '!!somethingelse'; // $config['custom_tripcode']['##securetrip'] = '!!somethingelse';
// TODO: description
$config['spoiler_images'] = false;
/* /*
* ==================== * ====================
* Image settings * Image settings
@ -330,6 +334,8 @@
// Thumbnail to use for the downloadable files (not images) // Thumbnail to use for the downloadable files (not images)
$config['file_thumb'] = 'static/file.png'; $config['file_thumb'] = 'static/file.png';
// Thumbnail to use for spoiler images
$config['spoiler_image'] = 'static/spoiler.png';
// Thumbnail quality (compression level), from 0 to 9 // Thumbnail quality (compression level), from 0 to 9
$config['thumb_quality'] = 7; $config['thumb_quality'] = 7;

18
inc/display.php

@ -339,6 +339,9 @@
$built .= '<p class="fileinfo">' . $built .= '<p class="fileinfo">' .
'File: <a href="' . $config['uri_img'] . $this->file . '">' . $this->file . '</a> ' . 'File: <a href="' . $config['uri_img'] . $this->file . '">' . $this->file . '</a> ' .
'<span class="unimportant">(' . '<span class="unimportant">(' .
($this->thumb == 'spoiler' ?
'Spoiler Image, '
: '') .
// Filesize // Filesize
format_bytes($this->filesize) . format_bytes($this->filesize) .
// File dimensions // File dimensions
@ -372,7 +375,11 @@
($this->thumb == 'file' ? ($this->thumb == 'file' ?
$config['file_thumb'] $config['file_thumb']
: :
$config['uri_thumb'] . $this->thumb ($this->thumb == 'spoiler' ?
$config['spoiler_image']
:
$config['uri_thumb'] . $this->thumb
)
) . ) .
'" style="width:' . $this->thumbx . 'px;height:' . $this->thumby . 'px;" alt="" /></a>'; '" style="width:' . $this->thumbx . 'px;height:' . $this->thumby . 'px;" alt="" /></a>';
} elseif($this->file == 'deleted') { } elseif($this->file == 'deleted') {
@ -505,6 +512,9 @@
$built = '<p class="fileinfo">' . $built = '<p class="fileinfo">' .
'File: <a href="' . $config['uri_img'] . $this->file . '">' . $this->file . '</a> ' . 'File: <a href="' . $config['uri_img'] . $this->file . '">' . $this->file . '</a> ' .
'<span class="unimportant">(' . '<span class="unimportant">(' .
($this->thumb == 'spoiler' ?
'Spoiler Image, '
: '') .
// Filesize // Filesize
format_bytes($this->filesize) . format_bytes($this->filesize) .
// File dimensions // File dimensions
@ -538,7 +548,11 @@
($this->thumb == 'file' ? ($this->thumb == 'file' ?
$config['file_thumb'] $config['file_thumb']
: :
$config['uri_thumb'] . $this->thumb ($this->thumb == 'spoiler' ?
$config['spoiler_image']
:
$config['uri_thumb'] . $this->thumb
)
) . ) .
'" style="width:' . $this->thumbx . 'px;height:' . $this->thumby . 'px;" alt="" /></a>'; '" style="width:' . $this->thumbx . 'px;height:' . $this->thumby . 'px;" alt="" /></a>';
} elseif($this->file == 'deleted') { } elseif($this->file == 'deleted') {

19
post.php

@ -459,7 +459,6 @@
} }
} }
// create image object // create image object
$image = new Image($post['file'], $post['extension']); $image = new Image($post['file'], $post['extension']);
@ -471,23 +470,29 @@
$post['width'] = $image->size->width; $post['width'] = $image->size->width;
$post['height'] = $image->size->height; $post['height'] = $image->size->height;
if($config['minimum_copy_resize'] && if($config['spoiler_images'] && isset($_POST['spoiler'])) {
$post['thumb'] = 'spoiler';
$size = @getimagesize($config['spoiler_image']);
$post['thumbwidth'] = $size[0];
$post['thumbheight'] = $size[1];
} elseif($config['minimum_copy_resize'] &&
$image->size->width <= $config['thumb_width'] && $image->size->width <= $config['thumb_width'] &&
$image->size->height <= $config['thumb_height'] && $image->size->height <= $config['thumb_height'] &&
$post['extension'] == ($config['thumb_ext'] ? $config['thumb_ext'] : $post['extension'])) { $post['extension'] == ($config['thumb_ext'] ? $config['thumb_ext'] : $post['extension'])) {
// Copy, because there's nothing to resize // Copy, because there's nothing to resize
copy($post['file'], $post['thumb']); copy($post['file'], $post['thumb']);
$post['thumbwidth'] = $image->size->width; $post['thumbwidth'] = $image->size->width;
$post['thumbheight'] = $image->size->height; $post['thumbheight'] = $image->size->height;
} else { } else {
$thumb = $image->resize($config['thumb_ext'] ? $config['thumb_ext'] : $post['extension'], $config['thumb_width'], $config['thumb_height']); $thumb = $image->resize($config['thumb_ext'] ? $config['thumb_ext'] : $post['extension'], $config['thumb_width'], $config['thumb_height']);
$thumb->to($post['thumb']); $thumb->to($post['thumb']);
$post['thumbwidth'] = $thumb->width; $post['thumbwidth'] = $thumb->width;
$post['thumbheight'] = $thumb->height; $post['thumbheight'] = $thumb->height;
$thumb->_destroy(); $thumb->_destroy();
} }
$image->destroy(); $image->destroy();
@ -531,7 +536,7 @@
// Remove DIR_* before inserting them into the database. // Remove DIR_* before inserting them into the database.
if($post['has_file']) { if($post['has_file']) {
$post['file'] = substr_replace($post['file'], '', 0, strlen($board['dir'] . $config['dir']['img'])); $post['file'] = substr_replace($post['file'], '', 0, strlen($board['dir'] . $config['dir']['img']));
if($is_an_image) if($is_an_image && $post['thumb'] != 'spoiler')
$post['thumb'] = substr_replace($post['thumb'], '', 0, strlen($board['dir'] . $config['dir']['thumb'])); $post['thumb'] = substr_replace($post['thumb'], '', 0, strlen($board['dir'] . $config['dir']['thumb']));
} }

2
templates/index.html

@ -61,7 +61,7 @@
</th> </th>
<td> <td>
<input style="float:left;" type="text" name="subject" size="25" maxlength="100" autocomplete="off" /> <input style="float:left;" type="text" name="subject" size="25" maxlength="100" autocomplete="off" />
<input accesskey="s" style="margin-left:2px" type="submit" name="post" value="{config[button_newtopic]=New Topic}" /> <input accesskey="s" style="margin-left:2px" type="submit" name="post" value="{config[button_newtopic]=New Topic}" />{config[spoiler_images]? <input name="spoiler" type="checkbox"/> Spoiler Image}
</td> </td>
</tr> </tr>
<tr> <tr>

2
templates/thread.html

@ -60,7 +60,7 @@
</th> </th>
<td> <td>
<input style="float:left;" type="text" name="subject" size="25" maxlength="100" autocomplete="off" /> <input style="float:left;" type="text" name="subject" size="25" maxlength="100" autocomplete="off" />
<input accesskey="s" style="margin-left:2px" type="submit" name="post" value="{config[button_reply]=New Reply}" /> <input accesskey="s" style="margin-left:2px" type="submit" name="post" value="{config[button_reply]=New Reply}" />{config[spoiler_images]? <input name="spoiler" type="checkbox"/> Spoiler Image}
</td> </td>
</tr> </tr>
<tr> <tr>

Loading…
Cancel
Save