PDA

View Full Version : BMP Images


Boofo
06-06-2002, 10:23 PM
I want to have it so I can view BMP images just like gifs when they are an attachment. I have added it in one place in the functions.php already, do I need to add it anywhere else? (Like for private attachments?) Also, how can I put commas between the file types in the attachment box? And will adding the different file types in the admin CP allow them to be able to be attached or is there something else I must do?

Boofo
06-07-2002, 08:00 AM
Here's the code I added to view bmps. In admin/functions.php, I replaced this:
if ($post[attachmentid]!=0 and $post[attachmentvisible]) {
$post[attachmentextension]=strtolower(getextension($post[filename]));
if ($post[attachmentextension]=="gif" or $post[attachmentextension]=="jpg" or $post[attachmentextension]=="jpeg" or $post[attachmentextension]=="jpe" or $post[attachmentextension]=="png") {
if (($viewattachedimages) and ($bbuserinfo[userid]==0 or $bbuserinfo[showimages])) {


with:

if ($post[attachmentid]!=0 and $post[attachmentvisible]) {
$post[attachmentextension]=strtolower(getextension($post[filename]));
if ($post[attachmentextension]=="gif" or $post[attachmentextension]=="jpg" or $post[attachmentextension]=="jpeg"
or $post[attachmentextension]=="jpe" or $post[attachmentextension]=="png" or $post[attachmentextension]=="bmp") {
if (($viewattachedimages) and ($bbuserinfo[userid]==0 or $bbuserinfo[showimages])) {


and in /root/attachment.php, I replaced:

if ($extension=='gif') {
header('Content-type: image/gif');
} elseif ($extension=='jpg' or $extension=='jpeg') {
header('Content-type: image/pjpeg');
} elseif ($extension=='png') {
header('Content-type: image/png');
} elseif ($extension=='pdf') {
header('Content-type: application/pdf');
} else {
header('Content-type: unknown/unknown');
}


with:

if ($extension=='gif') {
header('Content-type: image/gif');
} elseif ($extension=='jpg' or $extension=='jpeg') {
header('Content-type: image/pjpeg');
} elseif ($extension=='png') {
header('Content-type: image/png');
} elseif ($extension=='bmp') {
header('Content-type: image/bmp');
} elseif ($extension=='pdf') {
header('Content-type: application/pdf');
} else {
header('Content-type: unknown/unknown');
}


I know the second part of the code is for viewing bmps online, but I'm not sure what the first part does. It has to do with the attachment editor in some way, but I'm not quite sure what yet.

What I need to know is, do I need to add this anyplace else (like for the private attachments) or will this handle that also? And is there any way to come up with the filesize in the post next to an attachment so the user can decide if they want to wait to view it? I mean, if the filesize is too big and they are on dialup, it might be good to know the size of the file so they can decide if they want to wait for it to download to view.

Also, is there a way to add something like a box as the graphic file is downloading for viewing to let the user know how long it will take? Almost like the downloading box. If anyone can please help me, I would really appreciate it. :)

Admin
06-07-2002, 12:52 PM
The first change shows the attachment as an image, if it's of BMP format.

A hack was released to only show images smaller than X kb's, search the Releases, AFAIK it was by nicksaunder.

Boofo
06-07-2002, 12:59 PM
Thanks for the reply. Ok, I understand the first part now, but what does the second part do then? Do I need both parts to view a bmp file then? And do I need to put the code for bmps anywhere else?

And what I was really looking for is maybe after the word "Attachment", have it say what the size of the file is in the message itself.

Originally posted by FireFly
The first change shows the attachment as an image, if it's of BMP format.

A hack was released to only show images smaller than X kb's, search the Releases, AFAIK it was by nicksaunder.

Admin
06-07-2002, 01:22 PM
The second part is when you link directly to a BMP attachment, it will show it instantly without having to download it first.

Hack: :)
https://vborg.vbsupport.ru/showthread.php?s=&threadid=36828&highlight=attachment+%2Asize

Boofo
06-07-2002, 01:37 PM
Ahhh...I see now. But if the bmp is large enough (like 1.5 meg), then it still has to cache to the browser first before it can show, right? (Which would still take some time on a slow connection).

Great! Thanks! And thanks for the link. I just got finished looking for it and couldn't find it. :)

Originally posted by FireFly
The second part is when you link directly to a BMP attachment, it will show it instantly without having to download it first.

Hack: :)
https://vborg.vbsupport.ru/showthread.php?s=&threadid=36828&highlight=attachment+%2Asize

N!ck
06-07-2002, 09:32 PM
yeah, that wasn't me :)

Boofo
06-07-2002, 09:42 PM
Yeah, I kindof figured that. I know most of your hacks and I didn't remember seeing that one by you.

Originally posted by nicksaunders
yeah, that wasn't me :)

Boofo
06-08-2002, 12:19 PM
I just noticed that if I try to view a bmp (or whatever), it says it is downloading the post (in the status bar at the bottom of IE) before it goes to view it. That's just downloading it to the cache, I suppose. But shouldn't that second part of the code take care of that? I guess I'm a little confused here. :)
Originally posted by FireFly
The second part is when you link directly to a BMP attachment, it will show it instantly without having to download it first.

Admin
06-08-2002, 02:44 PM
You always download files (BMP or not) before you can view them, it's the nature of the internet. ;) :)

The only difference is, the second change you made enabled you to view the image directly in Internet Explorer (or whatever browser you are using), instead of having that window pop up and ask you to save the file.

Boofo
06-08-2002, 03:14 PM
Thanks, Chen, I think it is starting to make sense now. (finally, huh? :)) In order to be able to view it (like in the second part of the code, you have to let it know it is an image (by the code in the first part). I know I sound like an idiot on this, but it is working, so I must have it right somewhere. If I want to do the same thing in the private message attachment, do I need to change it anywhere else or will this code I replaced take care of it? And, one last thing, how can I get the commas between the attachment file extensions in the attachment box (like you have here)? :)

Originally posted by FireFly
You always download files (BMP or not) before you can view them, it's the nature of the internet. ;) :)

The only difference is, the second change you made enabled you to view the image directly in Internet Explorer (or whatever browser you are using), instead of having that window pop up and ask you to save the file.

Admin
06-08-2002, 03:35 PM
(1) Do the first change in private.php.

(2) Add the second line (right after the first, obviously):
$maxattachsize_temp = getmaxattachsize();
[high[ $attachextensions = str_replace(' ', ', ', $attachextensions);[/high]

Boofo
06-08-2002, 03:58 PM
If you mean the first code I did up a few posts ago, that code isn't in private.php anywhere. Is that what you meant?

Originally posted by FireFly
(1) Do the first change in private.php.


What do you mean here? And where do I put the code you gave me?


(2) Add the second line (right after the first, obviously):
$maxattachsize_temp = getmaxattachsize();
[high[ $attachextensions = str_replace(' ', ', ', $attachextensions);[/high]

Sorry to sound so lost here. :)

Admin
06-08-2002, 04:04 PM
In newreply.php and newthread.php replace this:
$maxattachsize_temp = getmaxattachsize();
With this:
$maxattachsize_temp = getmaxattachsize();
$attachextensions = str_replace(' ', ', ', $attachextensions);

Boofo
06-08-2002, 04:46 PM
Sorry about that. I was still thinkng about the private attachments problem. (DOHHH!!!)

Now, for the last part. You said to make a change in the private.php. What do I need to do to that do make it handle the BMPs the same way as the regular attachments does and how do I get the commas in there? :)

Originally posted by FireFly
In newreply.php and newthread.php replace this:
$maxattachsize_temp = getmaxattachsize();
With this:
$maxattachsize_temp = getmaxattachsize();
$attachextensions = str_replace(' ', ', ', $attachextensions);

Admin
06-08-2002, 04:49 PM
You can't do it for private messages, it doesn't work that way (sorry for misleading).

Boofo
06-08-2002, 05:19 PM
Then when you enter the vaid extensions in the vBulletin options and it shows it in the private attachment, it handles all of that differently, right? Is there a way to have it only show the ones it will be able to handle right then? :cheeky:

Originally posted by FireFly
You can't do it for private messages, it doesn't work that way (sorry for misleading).