PDA

View Full Version : Attachments Hack


Sebastian
10-18-2002, 02:33 PM
I apologize if a hack already exists:

1) I would like to center images on the post when a screenie gets uploaded, instead of it aligning to the left margin.

2) Be able to upload more than one image/attachment on a post.

3) Finally, When an image is uploaded have it resize to lets say 800x600 and if it was originally bigger make the image click-able so you can see the full image. That way big images can get uploaded without destroying the margins and making a thread look like crap.

Any of these options available, if not how hard will it be?

Thanks in advanced.

Tim Wheatley
10-18-2002, 02:57 PM
1 and 3 I can sort for you, just a sec...

Tim Wheatley
10-18-2002, 03:02 PM
Edit template: postbit_attachmentimage

Replace entire contents with:

<smallfont>$post[username] has attached this image:<p>
<center><a href="attachment.php?s=$session[sessionhash]&postid=$post[postid]"><img width="800" src="attachment.php?s=$session[sessionhash]&postid=$post[postid]" border="0" alt="Click to open the image in a new window" vspace="8" hspace="4"></smallfont></center></p>

Screenshot: (the mouse pointer is invisible on the screenie, but it was just next to the text in the yellow box)...

Sebastian
10-18-2002, 06:24 PM
Thanks a lot dude! Going to try it now :)

How hard will it be to make it possible to upload more than one image per post? I really would like that. Perhaps dublicate the attachment code or something? :P

Thanks again.

Tim Wheatley
10-18-2002, 06:35 PM
Something I've just thought of on my code above. If someone upload a SMALL image, it stretches it to 800. So if you want to remove the 800 width bit just remove:
width="800"

I'm not really very good with PHP, HTML is more my field, so someone else would have to help with multi-uploads. :)

Sebastian
10-18-2002, 07:31 PM
aww.. is there a way not to resize the image if it's smaller than 800x600?

I really, really want this bad :P
It makes the threads look so much cleaner.

Thanks again.

Sebastian
10-22-2002, 01:42 PM
Can anyone get this code not to resize an image if it's smaller than the size specified? This works awesome, in keeping threads clean :P

Tim Wheatley
10-23-2002, 10:12 AM
Well it will be within attachment.php, and would be easier done on file size I'd expect, with the > sign... But I can't help much...

Logician
10-24-2002, 10:35 AM
Tim's solution is wise and it forces the image to resize with HTML. But it is inevitable that all images will be forced to be in that size if you use HTML.

To make some (largers) resize and others (smalls) stay as it is you need to handle the job in PHP, not in HTML and to handle it your code needs to know what is the image size so that it can take actions accordingly.

Unfortunately I cant see an easy way to manage your goal in PHP. AFAIK the image size of the attachment is not saved in the attachment table so its not possible to know the dimensions of the image by checking your db. There is a special function "getimagesize" in PHP which would be a remedy for your problem but its not a default PHP function but a part of an additional image library. In other words so as to use this function (and to get the image size) your PHP should be equipped with image library by installing it. It's a server side library so your host must be installing it and for the same reason even if the solution is provided, it will not work for all users since many hosts wouldnt include this library in their PHP configuration.

As for multi-attachments hack: It's a long waited hack but not released here. Neo says he is working on it for a long time but if you make a list of hacks Neo says he is working on, you can really doubt if he can finish any of this very long list soon. :) I also know there is commercial version of this hack coded by someone and sold commercially. But I dont know his name..

Sebastian
10-24-2002, 02:29 PM
Thanks for the reply. I know it never can be done using .html, I haven't been using vb that long to know what files need to be edited, etc.. I didn't think this would be this complicated as I know a forum that has this feature implemented, though I think it's some sort of perl forums. maybe down the road as I get more familiar with vb I can do it myself. In the mean time I am sure a vb guru can knock this out in 10 minutes.

As for the attachment, I don't care for it as much, It would be useful.. I am hearing it's probably going to be added to vb3.

Thanks for the help.

Boofo
12-08-2002, 08:02 PM
Sinan, isn't there a way to make a table to store the image sizes in the database? Then you wouldn't have to use the server side image library, would you?