MOD: Simple image upload

Downloadable phpBB mods/hacks.

MOD: Simple image upload

Postby PostBot on Wed Aug 24, 2005 3:21 pm

Mod name: Simple image upload
Mod version: 1.0.0
Author: CyberAlien
phpBB version: 2.0.x (any version)

Description: This mod enables image uploading. All images are stored on image hosting server, not on your forum. Image uploading is very simple and requires no skill. This mod is perfect solution for forums where visitors are not tech savvy and don't know how to upload image or don't know how to use [img] bbcode. Image hosting script creates thumbnails of images and posts thumbnails instead of full images, so large images will be shown as small.

Mod code:

Create file "addform.html" in your forum root directory (for nuke if that won't work then you should create it in nuke root directory) and put this code in it (click on "download" link in code header to download it)[code filename="addform.html"]<html>
<head>
</head>
<body>
<script language="javascript" type="text/javascript">
<!--
function add_code()
{
var text = unescape(document.location.search.substring(1));
opener.document.forms['post'].message.value = opener.document.forms['post'].message.value + text;
opener.focus();
window.close();
}
add_code();
//-->
</script>
</body>
</html>[/code]
Then make this change to 'templates/subSilver/posting_body.tpl':
Code: Select all
#
#-----[ OPEN ]-------------------------------------------------------
#

templates/subSilver/posting_body.tpl

#
#-----[ FIND ]-------------------------------------------------------
#

        <tr>
         <td colspan="9"><span class="gen">
           <textarea name="message" rows="15" cols="35" wrap="virtual" style="width:450px" tabindex="3" class="post" onselect="storeCaret(this);" onclick="storeCaret(this);" onkeyup="storeCaret(this);">{MESSAGE}</textarea>
           </span></td>
        </tr>

#
#-----[ IN-LINE FIND ]-----------------------------------------------
#

{MESSAGE}</textarea>

#
#-----[ IN-LINE AFTER, ADD ]-----------------------------------------
#

<br /><span class="genmed"><a href="javascript:void(0);" onclick="window.open('http://www.postimage.org/index.php?mode=phpbb&tpl=.&forumurl=' + escape(document.location.href), '_imagehost', 'resizable=yes,width=500,height=400');return false;">Add image to post</a></span>

#
#-----[ SAVE/CLOSE ALL FILES ]---------------------------------------
#
# EoM

That's all. This is the simpliest attachment mod there is. And you don't need to worry about disk space because all images are hosted on third party server.


__________________________________________________________________________________

How it works:

Uploading images is as simple as it can get:

1. When starting new thread or posting reply you see "add image to post" link below textarea:
Image

2. Click that link, popup will appear where you should select image and add description to that image (description is optional):
Image

3. You click "upload it" link, image is uploaded and bbcode is automatically inserted in post:
Image

4. You click "submit" to submit post and thumbnail of image appears in post (just like thumbnails posted above)
Do NOT pm me, I don't visit this forum anymore, don't own it, don't provide any support and don't moderate.
User avatar
PostBot
Moderator
Moderator
 
Posts: 10659
Joined: Sat Aug 02, 2003 3:52 pm
Location: Mars

Postby PostBot on Sat Sep 03, 2005 2:07 pm

This is modification of mod if you have lots of styles installed and don't want to edit all styles:

1. Upload addform.html as written in previous post

2. Install eXtreme Styles mod if you don't have it installed yet

3. Open includes/template.php and do following replacements:

find this
Code: Select all
   var $replace = array();
add after it
Code: Select all
   var $is_posting = false;
find this
Code: Select all
      // checking if we have valid filename
      if(!$this->files[$handle])
      {
         if($xs_include || $quiet)
         {
            return false;
         }
         else
         {
            die("Template->make_filename(): Error - invalid template $filename");
         }
      }
add after it
Code: Select all
      // check for posting_body.tpl
      if($filename === 'posting_body.tpl')
      {
         $this->is_posting = $handle;
      }
find this
Code: Select all
   function pparse($handle)
   {
      global $board_config;
add after it
Code: Select all
      // check for posting_body.tpl
      $is_posting = ($this->is_posting && $handle === $this->is_posting) ? true : false;
find this
Code: Select all
         if(!empty($this->files_cache2[$handle]) && empty($this->files_cache[$handle]) && !$force_recompile)
         {
            $this->compiled_code[$handle] = $this->compile2($this->uncompiled_code[$handle], $handle, $this->files_cache2[$handle]);
         }
         else
         {
            $this->compiled_code[$handle] = $this->compile2($this->uncompiled_code[$handle], '', '');
         }
and replace with this
Code: Select all
         if(!empty($this->files_cache2[$handle]) && empty($this->files_cache[$handle]) && !$force_recompile)
         {
            $this->compiled_code[$handle] = $this->compile2($this->uncompiled_code[$handle], $handle, $this->files_cache2[$handle], $is_posting);
         }
         else
         {
            $this->compiled_code[$handle] = $this->compile2($this->uncompiled_code[$handle], '', '', $is_posting);
         }
find this
Code: Select all
   function compile_code($filename, $code, $use_isset = false)
and replace with this
Code: Select all
   function compile_code($filename, $code, $use_isset = false, $is_posting = false)
find this
Code: Select all
      // load code from file
      if(!$code && !empty($filename))
      {
         $code = @implode('', @file($filename));
      }
and add after it
Code: Select all
      // Add image upload mod
      if($is_posting && strpos($code, 'postimage.org') === false)
      {
         $code = str_replace('</textarea>', '</textarea><br /><span class="genmed"><a href="javascript:void(0);" onclick="window.open(\'http://www.postimage.org/index.php?mode=phpbb&tpl=.&forumurl=\' + escape(document.location.href), \'_imagehost\', \'resizable=yes,width=500,height=400\');return false;">Add image to post</a></span>', $code);
      }
find this
Code: Select all
   function compile2($code, $handle, $cache_file)
   {
      $code = $this->compile_code('', $code, XS_USE_ISSET);
and replace with this
Code: Select all
   function compile2($code, $handle, $cache_file, $is_posting = false)
   {
      $code = $this->compile_code('', $code, XS_USE_ISSET, $is_posting);

That's all.

Its much more complex than original mod, but it is easier to add if you have more than 10 styles installed on your forum (for example, for forum hosting service).

Make sure you clear cache in extreme styles mod menu after applying these changes.
Do NOT pm me, I don't visit this forum anymore, don't own it, don't provide any support and don't moderate.
User avatar
PostBot
Moderator
Moderator
 
Posts: 10659
Joined: Sat Aug 02, 2003 3:52 pm
Location: Mars

Language support

Postby PostBot on Wed Sep 14, 2005 10:57 am

Hello,

Now image hosting mod supports different languages. All you have to do is add parameter "lang" to popup url in posting_body.tpl like this (see highlighted code):

replace
Code: Select all
http://www.postimage.org/index.php?mode=phpbb&tpl=
with
Code: Select all
http://www.postimage.org/index.php?mode=phpbb[highlight]&lang=italian[/highlight]&tpl=


Currently available languages:
- Bosnian
- Catalan
- Danish
- Dutch
- English (default, if any other language isn't specified)
- Estonian
- French
- German
- Italian
- Portuguese
- Portuguese_brazil
- Slovak
- Slovenian
- Spanish
- Swedish
- Turkish
- Vietnam
Do NOT pm me, I don't visit this forum anymore, don't own it, don't provide any support and don't moderate.
User avatar
PostBot
Moderator
Moderator
 
Posts: 10659
Joined: Sat Aug 02, 2003 3:52 pm
Location: Mars

Simple image upload for vBulletin

Postby PostBot on Wed Jan 11, 2006 10:43 pm

Few vBulletin forums wanted to have this mod too, so here is vBulletin version of mod:

1. create "addform.html" in your forum directory, put this code in it:[code filename="addform.html"]<html>
<head>
</head>
<body>
<script language="javascript" type="text/javascript">
<!--
function add_code()
{
var text = unescape(document.location.search.substring(1));
opener.document.forms['vbform'].message.value =
opener.document.forms['vbform'].message.value + text;
opener.focus();
window.close();
}
add_code();
//-->
</script>
</body>
</html>[/code]
2. Edit templates "editor_toolbar_off" and "editor_toolbar_on" (this is for vBulletin 3.5.x, template names for other versions might be different). Find </textarea> and put this code after it:
Code: Select all
<br /><span class="genmed"><a href="javascript:void(0);" onclick="window.open('http://www.postimage.org/index.php?mode=phpbb&tpl=.&forumurl=' + escape(document.location.href), '_imagehost', 'resizable=yes,width=500,height=400');return false;">Add image to post</a></span>
All parameters to popup are exactly the same as in phpBB version. You can change language same way.
Do NOT pm me, I don't visit this forum anymore, don't own it, don't provide any support and don't moderate.
User avatar
PostBot
Moderator
Moderator
 
Posts: 10659
Joined: Sat Aug 02, 2003 3:52 pm
Location: Mars


Return to phpBB 2.0 Mods

Who is online

Users browsing this forum: No registered users and 0 guests

cron