1 (edited by Koos 2008-10-13 15:48)

Topic: Automatic Image Upload with Thumbnails

##
##        Mod title:  Automatic Image Upload with Thumbnails
##
##      Mod version:  1.3.5
##   Works on PunBB:  1.2.*
##     Release date:  2008-06-15
##           Author:  Koos (pampoen10@yahoo.com)
##
##      Description:  This tool allows users to upload images and automatically
##                    creates thumbnails for them which can then be displayed
##                    in your forum posts. Clicking the thumbnail shows the
##                    original image. By only displaying thumbnails pages load
##                    quicker. This is not really a "MOD" since no punbb files
##                    have to be modified and the database is not affected.
##                    This makes for very easy installation and removal if
##                    needed. Also no changes are necessary when upgrading 
##                    your punbb forum.
##
##   Affected files:  none
##                                     
##       Affects DB:  no
## 
##            Notes:  Requires the GD library on your Web server. Script can
##                    upload JPEG, PNG AND GIF images.
##
##       DISCLAIMER:  Please note that "mods" are not officially supported by
##                    PunBB. Installation of this modification is done at your
##                    own risk. Backup your forum database and any and all
##                    applicable files before proceeding.
##
################################################################################
## CHANGELOG:
## 1.3.5 : made the necessary changes so that sorting will work in PHP5
##         fixed a serious vulnerability
##         other minor changes
## 1.3.4 : rewrote the 'uploadimg.php' page
##         fixed a vulnerability
##         all pages now valid XHTML 1.0 Strict
##         stats totals now also include thumb size
## 1.3.3 : fixed thumbnail creation bug
##         - previously, when width<twidth and height>theight: no resize
##         removed dimensions column in list view
##         other minor fixes
## 1.3.2 : added statement allocating all necessary memory for image processing
##         transliterates filenames with umlauts, accents, ligatures and runes 
##         added dimensions column to list of uploaded images
##         fixed bug resulting in interrupted uploads being saved
##         other minor changes
## 1.3.1 : much improved thumbnail and image resize quality
##         improved 'resize image' function
##         more efficient use of PHP memory - can now resize larger images
##         removed user id from statistics table
##         other minor changes
## 1.3.0 : strips all non-alphanumeric characters in filename
##         fixed image resize aspect ratio problem
##         added delete functionality
##         added option to resize images on upload
##         added option to view image URL link below thumbnail in the gallery
##         thumbnail now shown on the results page after upload
##         other minor fixes and improvements
## 1.2.2 : totals now shown in the 'upload statistics' table
##         added language support
##         fixed: upload not saved if thumbnail can not be created
##         fixed: PNG Image file interpretation problem in IE
##         - (ie6 sends image/x-png instead of image/png)
##         other minor changes
## 1.2.1 : BBCode now generated below each thumbnail in the gallery
##         - like Photobucket/ImageShack
## 1.2.0 : changed layout to conform more closely to the punbb standard
##         added an 'upload statistics' feature
##         added flickr style gallery feature - with latest upload displayed first
##         added full permission control
##         all spaces in filenames of uploaded images now replaced with _ (underscore)
##         dates in upload list now displayed as in the rest of your forum
##         other minor improvements
## 1.1.1 : fixed compatibility problem with Internet Explorer
##         some other minor fixes
## 1.1.0 : added support for PNG and GIF files
##         simplified  configuration (don't have to specify absolutepath or forumurl)
## 1.0   : initial release 
################################################################################

I have recently completed an 'upload with automatic thumbnail creation' tool. The great thing about this "MOD" is that you don't have to make any changes to your punbb files or the database.

Features:

* Extremely easy to install and remove
* Can view a list and gallery of all your uploaded images
* Can not replace a file with same filename
* Can create thumbnails of JPEG, PNG and GIF files (depending on your GD version)
* Can specify maximum file size to upload
* Can view upload statistics of users who have uploaded images

How it works:

1. You select an image file to upload e.g. image.jpg
2. The image is uploaded with your pun user id used as the prefix e.g. 12_image.jpg - this is to differentiate your uploads from the uploads of other users.
3. Thumbnail is created in the thumbnails directory
4. You are supplied with the code which you must copy and paste into your post. This allows the thumbnail of your uploaded image to be displayed in your post. Clicking the thumbnail shows the original image.

Note:

The easiest way to see whether the GD library has been installed on your Web server and which file types it supports is to create a small file (e.g. test.php) containing:

        <?php phpinfo() ?>

    and look at it using a web browser. There you will also be able to see what your PHP memory limit is (see the memory_limit parameter). It is recommended that this is at least 16MB for proper thumbnail creation operation. Ask your system administrator to raise it for you. With 16MB of PHP memory you will be able to create thumbnails of images of up to about 2000x1500 pixels in size. Uploading larger images you get a blank screen (symptom of memory max-out).

Update:
Added statement in v1.3.2 for allocating all necessary memory for image processing. On some servers this will allow you to upload and resize any size image.

Download from punres.org

2 (edited by axa 2007-03-20 01:54)

Re: Automatic Image Upload with Thumbnails

A positively awesome little add-on. I wish all mods were this easy.
Just dawned on me - there is nothing stopping anyone from registering on one's forum, and uploading pics to leech bandwidth, right ?

Landen Meadows Residents Forum - http://www.landenmeadows.net

3 (edited by Koos 2007-03-20 22:32)

Re: Automatic Image Upload with Thumbnails

axa wrote:

A positively awesome little add-on. I wish all mods were this easy.
Just dawned on me - there is nothing stopping anyone from registering on one's forum, and uploading pics to leech bandwidth, right ?

You're right. Have you got any suggestions? Maybe only allow an user to upload images after he has posted a certain number of posts - or maybe an admin page where you can give users permission to upload (users will then have to request permission for uploading). This admin page should be able to tell you how much uploads (in MB) each user has made and also allow you to browse his gallery (only for admin) etc. Might also be a good idea to hotlink protect the images on your website to save bandwidth.

What do you think?

I am also currently working on a feature which will allow you to view all your uploaded images as a gallery (like with flickr).

4

Re: Automatic Image Upload with Thumbnails

A minimum number of posts as a first security would be good, indeed.

The idea of the admin page is very good too smile


Can you make a combination of these two options?

5 (edited by Koos 2007-03-21 00:20)

Re: Automatic Image Upload with Thumbnails

-J- wrote:

A minimum number of posts as a first security would be good, indeed.

The idea of the admin page is very good too smile


Can you make a combination of these two options?

On second thought, minimum post idea not very practical - easy to get past - just post the number of blank posts required and then delete them. (your number of posts are not decremented in punbb when deleting posts)

A better idea is maybe to add a new usergroup (e.g. Uploader) and then to promote members to the rank of 'Uploader'. Only 'Uploaders' will have permission to upload images.

Re: Automatic Image Upload with Thumbnails

Indeed: a group option (disabled by default but enabled for mods/admins) sounds like the right idea here smile

Re: Automatic Image Upload with Thumbnails

A nice, very nice feature would be to put text next to the image, like in the magazines. To get that is quite easy, an example here below

<p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt.....
<img src="our_img.jpg" alt="info" align="left" >Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor 
invidunt.....</p>

To get the same in our forum, we need to edit  the file include/parser.php

    change this line:
$img_tag = '<img class="sigimage"  src="'.$url.'" alt="'.htmlspecialchars($url).'" />';

with this one below:
    $img_tag = '<img class="sigimage"  src="'.$url.'" alt="'.htmlspecialchars($url).'" align="left"  hspace="10" vspace="10" />';

note that (hspace="10" vspace="10") add some space betwen the image and the text!

That's to give the Idea, but you won't like the image allways on the left, sometime you need to set align to  center or right. One way to  do that is educating the parser to read the align inside the img tag. another way maybe easyer to implement is to set a select when you post a new comment and you pass with the  form in a variable the instruction to set the align!

see ya
kirk

8 (edited by Koos 2007-03-21 12:34)

Re: Automatic Image Upload with Thumbnails

beipink wrote:

A nice, very nice feature would be to put text next to the image, like in the magazines. To get that is quite easy, an example here below

Thanks for the idea - but it is already possible to to this. Just type your text right after inserting the code of the image - the text will then display next to the image.

Anyway, with my "MOD" my aim is to leave all punbb files and the database unaffected - so I will not require you to make any modifications to existing punbb pages.

9 (edited by Koos 2007-03-21 19:29)

Re: Automatic Image Upload with Thumbnails

Like I said earlier: my plan was to add a new usergroup (e.g. Uploader) and then to promote members to the rank of 'Uploader'. Only 'Uploaders' will have permission to upload images.

But won't it be better to allow all members to upload images- and then create a usergroup 'Banned Uploaders'? Then all members can upload - and you only ban those users that misuse the system from uploading.

Any suggestions?

Re: Automatic Image Upload with Thumbnails

I think just having it as a regular group option is ideal. Then, if a forum wants to go with the "Banned Uploaders" idea, they can. And if another forum wants to have a special group for "Uploaders" they can as well wink

Re: Automatic Image Upload with Thumbnails

suggestion: multiple upload slots. ie: the ability to upload 5, 10, 15 images at once.

~James
FluxBB - Less is more

Re: Automatic Image Upload with Thumbnails

This is an amazing mod.   Almost too simple to implement and use... I couldn't believe how easy it was to install and use.  Koos, I hope you stick around for a long time to keep creating mods!!!

Regarding leaching bandwidth.   I use to be more worried about this then I am now that BW allotments have been increasing for hosting accounts.    This may be rudimentary, but so far it works for me:

1)  Limit the size of the files that can be uploaded.  If it is 200 kb then only so much damage can be done at once.
2)  Keep an eye on your bandwidth... if you see a spike, check your logs to see where it is coming from.
3)  If my logs show a single image eating up a ton of BW I would delete the image and ban the user.

Other than that, the only way to really keep a handle on this (other than the ways you guys are already discussing) is to have a max # of image downloads per day, etc... but then everything (I believe) would need to pass through a DB, etc.

The main thing I'd like to see added is the ability to resize the original image on upload so members can just resize to meet the max limit on the spot.

Rob Ludlow 
www.Nifty-Stuff.com - Repository of all Stuff Nifty!
www.reviewum.com - Professor Ratings + Teacher Reviews

Re: Automatic Image Upload with Thumbnails

images show up as urls not images if there is a space in the image file name...which is why I won't be using this just yet.

Also is there an easy way to switch from not using thumbnails...I would prefer this I think.

Would be really cool if this mod could make use of Ajax...so you could start writing a message and when you want an image then you just click insert image the image is uploaded and the correct url with IMG tags is stuck strait into your post field without even refreshing the page.

I don't think this would be too hard to do and would put an end to my search for a truly good image upload solution for punbb.

(sorry for posting same thing here and on punres)

Punbb w/coppermine and wordpress integrated

see my hack to integrate punbb with wordpress comment system.
Illustration Community

14

Re: Automatic Image Upload with Thumbnails

nickfzx wrote:

images show up as urls not images if there is a space in the image file name...which is why I won't be using this just yet.

Proper operating systems wouldn't use any spaces in filenames. big_smile Seriously though, all you need to do is slightly modify the uploadimg.php script to include quotes around the urls, so it's "http:/path/to/file" instead of unquoted.

Re: Automatic Image Upload with Thumbnails

I'm not a programmer, but I'd like to see the file name changed on upload to convert spaces to _ or to -

I really like where this script is going.  A lot of potential here. 

BTW, anybody else think that resizing the image on upload or giving the option to resize on upload is a good idea?   My users will have a hard time trying to resize images locally and if the uploader can do it... great!

Rob Ludlow 
www.Nifty-Stuff.com - Repository of all Stuff Nifty!
www.reviewum.com - Professor Ratings + Teacher Reviews

Re: Automatic Image Upload with Thumbnails

MattF wrote:
nickfzx wrote:

images show up as urls not images if there is a space in the image file name...which is why I won't be using this just yet.

Proper operating systems wouldn't use any spaces in filenames. big_smile Seriously though, all you need to do is slightly modify the uploadimg.php script to include quotes around the urls, so it's "http:/path/to/file" instead of unquoted.

oh cool...yeah i know filenames shouldn't have spaces but if lots of people use a forum then I can't expect them all to understand this.

Punbb w/coppermine and wordpress integrated

see my hack to integrate punbb with wordpress comment system.
Illustration Community

17

Re: Automatic Image Upload with Thumbnails

reviewum.com wrote:

I'm not a programmer, but I'd like to see the file name changed on upload to convert spaces to _ or to -

I really like where this script is going.  A lot of potential here. 

BTW, anybody else think that resizing the image on upload or giving the option to resize on upload is a good idea?   My users will have a hard time trying to resize images locally and if the uploader can do it... great!

Just checked. It does leave spaces intact, and you can't use quotes in the [img] tags. M$ has a lot to answer for, spaces in filenames indeed........ big_smile Spaces ought to be stripped and replaced, but resizing your final image should be done before upload. If you want the script to do that, then it's a case of altering it. Just copy the thumbnail generation code, if you want to incorporate it. Either that or ask Koos nicely if he might be inclined to adding the option to his script. big_smile

18

Re: Automatic Image Upload with Thumbnails

I have nearly finished my next version of this mod (v1.20). Will be available within a day or two.

reviewum.com wrote:

The main thing I'd like to see added is the ability to resize the original image on upload so members can just resize to meet the max limit on the spot.

The original script I made was able to do this (before making it available as a MOD) - but it only resized to a given pixel width, not size. Will see what I can do to give an option of resizing to meet the max limit. (good idea)


nickfzx wrote:

images show up as urls not images if there is a space in the image file name...which is why I won't be using this just yet.

I will correct this in the next version - all spaces will be replaced by _ (underscore)

nickfzx wrote:

Also is there an easy way to switch from not using thumbnails...I would prefer this I think.

With the next version's gallery view one will be able to get the url of the original image easily. This can then be used if you want to display the original image without the thumbnail.

nickfzx wrote:

Would be really cool if this mod could make use of Ajax...so you could start writing a message and when you want an image then you just click insert image the image is uploaded and the correct url with IMG tags is stuck strait into your post field without even refreshing the page.

I don't know anything about Ajax - will look into this.

Re: Automatic Image Upload with Thumbnails

outstanding Koos. can't wait.

~James
FluxBB - Less is more

20 (edited by Koos 2007-04-02 18:28)

Re: Automatic Image Upload with Thumbnails

I have finally completed version 1.2. With this version I have made quite a number of improvements. See the changelog for more info. Thanks to all for their suggestions.

Re: Automatic Image Upload with Thumbnails

improvements look fantastic...I will try it out now...thanks for making this mod

Punbb w/coppermine and wordpress integrated

see my hack to integrate punbb with wordpress comment system.
Illustration Community

Re: Automatic Image Upload with Thumbnails

initial thoughts...great update, having spaces replaced with underscores makes it much more appealing to me.

In the gallery view there should be a "get code" button under each thumbnail...better still a little auto-copy-to-clipboard box like photobucket do.

Also it would be cool if there was a config option that changed the outputted code to the whole image instead of a thumbnail linking to the image.


I think this plugin would be far better if it was integrated into post.php so that users could do the whole uploading thing as they are making a post. And the gallery was under the post box so you could easily insert images into the post without having to leave the post page.

This is my thoughts anyway.

Punbb w/coppermine and wordpress integrated

see my hack to integrate punbb with wordpress comment system.
Illustration Community

23 (edited by Koos 2007-04-03 23:18)

Re: Automatic Image Upload with Thumbnails

nickfzx wrote:

In the gallery view there should be a "get code" button under each thumbnail...better still a little auto-copy-to-clipboard box like photobucket do.

I agree. I made an update (v1.2.1) where the BBCode is generated below each thumbnail in the gallery- like Photobucket/ImageShack.

Re: Automatic Image Upload with Thumbnails

Looks excellent!  I've already added it to one of my forums and the feedback has been great.  Any chance there will be an option for resizing on upload?  big_smile

BTW, I still like the fact that this "mod" is independent of any DB / File modifications.  Simple, clean, easy to add and easy to remove.  This is how I dream that the extentions in 1.3 will work.

Rob Ludlow 
www.Nifty-Stuff.com - Repository of all Stuff Nifty!
www.reviewum.com - Professor Ratings + Teacher Reviews

25 (edited by Koos 2007-04-04 12:27)

Re: Automatic Image Upload with Thumbnails

reviewum.com wrote:

Looks excellent!  I've already added it to one of my forums and the feedback has been great.  Any chance there will be an option for resizing on upload?  big_smile

BTW, I still like the fact that this "mod" is independent of any DB / File modifications.  Simple, clean, easy to add and easy to remove.  This is how I dream that the extentions in 1.3 will work.

Thanks - I am still looking into including the resizing option. Just got to figure out how to deal with the pixel dimension limit. When uploading large pixel dimension images you get a blank screen (symptom of memory max-out).

For example: resizing a low quality  1613x1210 (70KB) image you get a blank screen.

On the contrary: resizing a high quality 1000x800 (1137KB) image works perfectly.