PDA

View Full Version : Miscellaneous Hacks - NoMoreGifs


Zachery
03-07-2007, 10:00 PM
I had been working on a style for my now defunt site, while developing it, since IE7 was final and PNG's are just too cool to pass up anymore. I found it a pain to re-write all of the vBulletin templates to use the .png extension on the images. Not to mention this would make upgrading a pain in the butt.

I had Matthew (https://vborg.vbsupport.ru/member.php?&username=Link14716) make me this snipet of code. I told him I would release it and he said its fine.

So to you I now give you the ability to not have to use gif's but png's in your image folders.

You're webserver must support custom error documents via htaccess.

Installation,
Edit htaccess file to give a full/proper url to your new 404.php document
Put both the htaccess file and the 404.php file in the base of you images folder.

I only offer support when I have time. This modification is otherwise unsupported, but working.


For style developers, if you wish to use this, please give credit where credit is due :), a link back to this mod would be great.

beduino
03-08-2007, 03:37 PM
Tks Zachery!
All the best
Beduino

Skavenger
03-08-2007, 03:41 PM
I don't understand very well, sorry... but, is this hack something like this?

http://homepage.ntlworld.com/bobosola/

Dan
03-08-2007, 03:42 PM
Awesome idea Zak :D pngs ftw

Zachery
03-08-2007, 03:43 PM
No, this allows you to use all png images without having to re-write vBulletin templates to do so.

Your browser will first look for a .gif file, if its not found, it sends a 404 error and thus a broken image. We use a custom 404 file to redirect to the same named image but .png and forward it to your browser.

So for example

https://vborg.vbsupport.ru/images/cstyle/blue/statusicon/user_online.gif https://vborg.vbsupport.ru/external/2010/01/8.gif
Normal image, you remove https://vborg.vbsupport.ru/images/cstyle/blue/statusicon/user_online.gif and add
https://vborg.vbsupport.ru/images/cstyle/blue/statusicon/user_online.png the 404 file will redirect to this instead.

Ziki
03-08-2007, 07:31 PM
No vB version?

Zachery
03-08-2007, 07:32 PM
It'd work for every version of vBulletin from vB Lite to vB 2020, this could even be used on other software, websites, etc.

Hornstar
03-09-2007, 01:08 PM
awesome work, thanks!

Ziki
03-09-2007, 10:03 PM
How can I do that to not select vb version

Zachery
03-10-2007, 01:28 AM
I'm just good.

kal-L
03-10-2007, 05:48 AM
:up: Great share my friend.

Subah
03-10-2007, 08:12 AM
Good job but my server does not support custom error documents via htaccess :(

Zachery
03-12-2007, 02:32 PM
Sadly thats not something i can fix :(

Atakan KOC
03-25-2007, 06:02 PM
Thanks........

Distance
07-21-2007, 09:19 PM
thanks but wont this affect the time loading images?

alessai
07-22-2007, 12:36 AM
thanks but wont this affect the time loading images?

:confused: yeah i was thinking about the same thing

Zachery
07-22-2007, 07:11 PM
It shouldn't.

R1lover
07-27-2007, 03:23 AM
Of course it will effect the loading times, maybe not by much but it all adds up.

It will be delayed the same as any typical redirection.

slyreptile
09-15-2007, 01:16 PM
Saves me a ton of time! Thanks!

SuperD
11-16-2007, 08:07 PM
Installation,
Edit htaccess file to give a full/proper url to your new 404.php document
Put both the htaccess file and the 404.php file in the base of you images folder.

Thanks for the hack and cannot wait to see it work :up:
Could anybody explain to me how to put a full/proper url to my new 404.php? dose this mean the new url after moving the file to the Images folder??? :confused:
Also I want to mention that I use PHP5, in this case should I move the file named 500.php instead?

Audentio
11-16-2007, 10:52 PM
Zachery, can I release this at MyBBoard.net? A link back to you and this thread as well as full credit to you, I just want to share it with them, this is fantastic!

Zachery
11-17-2007, 04:49 PM
I'll go release it over there at some point in the future.

Zachery
11-17-2007, 04:49 PM
Thanks for the hack and cannot wait to see it work :up:
Could anybody explain to me how to put a full/proper url to my new 404.php? dose this mean the new url after moving the file to the Images folder??? :confused:
Also I want to mention that I use PHP5, in this case should I move the file named 500.php instead?
You need to put a path to the file, like
http://www.mywebsite.com/forums/images/404.php

Audentio
11-18-2007, 08:48 PM
I'll go release it over there at some point in the future.

Awwwesome, tell me when you do! :)

legionofangels
04-09-2008, 03:37 AM
Will this work for all images of the entire forum?

Like lets say the reputation images?

Zachery
04-09-2008, 05:51 AM
ALL images.

legionofangels
04-09-2008, 02:26 PM
Thanks Z, I will check it out then.

Peace

legionofangels
04-19-2008, 06:02 PM
Do you have a demo site with this installed so I can preview it before using?

I'm guessing there is no way to restrict it to certain parts or certain images, rather than ALL of them is there?

Zachery
04-19-2008, 07:56 PM
If you dont want to use a png, dont delete the original gif.

feldon23
04-28-2008, 11:57 AM
What this thread needs is all the vBulletin graphics re-saved as transparent PNG. :)

Zachery
04-28-2008, 12:33 PM
I'm not that motovated feldon ;p

StGaensler
05-02-2008, 07:03 PM
I have two things to remark:

As you send a Location: header the Content-type: header doesn't matter as the browser makes a second request for the png file.

This second request takes some time so I suggest doing the "decision" directly on the server without the need of a second request. This only needs the Apache module mod_rewrite:RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*)\.gif$ $1.png [NC,L]Every non-existing gif file so gets redirected to a png file. I don't check if the png file exists but I think this doesn't matter ;)

Stefan

harakiri
05-02-2008, 07:36 PM
Thanks Stefan,

it feels "faster".

Regards,
Chris

Zachery
05-02-2008, 08:15 PM
I have two things to remark:

As you send a Location: header the Content-type: header doesn't matter as the browser makes a second request for the png file.

This second request takes some time so I suggest doing the "decision" directly on the server without the need of a second request. This only needs the Apache module mod_rewrite:RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*)\.gif$ $1.png [NC,L]Every non-existing gif file so gets redirected to a png file. I don't check if the png file exists but I think this doesn't matter ;)

Stefan
I don't always replace all of the gif files, so I prefer my version.

StGaensler
05-02-2008, 08:28 PM
Your version replaces all non existant gif files with png files - am I correct? Exactly the same does my code but without causing the second (unnecessary) request.

harakiri
05-03-2008, 06:41 AM
Both versions doing the _same_ thing - but in different ways.

If you have mod_rewrite on your Apache, I think the solution by Stefan is better.. else Zacherys

dannykilla
05-22-2008, 11:50 PM
will this work on 3.7.0?

StGaensler
05-24-2008, 12:52 PM
Don't know why it shouldn't?

dannykilla
07-04-2008, 07:47 AM
I am trying to get this to work on my board which is 3.7.2 and I have followed the instructions correctly and created a image called newthread.png and then uploaded it to the correct directory and then deleted the newthread.gif but when I refresh the page I just get text saying "post new thread" and no image?
I am running vB 3.7.2, PHP 5 and I have asked my host if I have the necessary setting that this hack/mod requires and then said YES?

Anyone help me out please?
Thanks
Danny

Prezadent
07-07-2008, 02:41 AM
You can easily rename a .png to a .gif and have the .png display normally in all major browsers.

No need for this hack.

Zachery
07-08-2008, 12:32 PM
You shouldn't though.

drapton
07-17-2008, 02:50 AM
thanks for this, it would be real helpful, but it's not working for me. instead of the png image i get a text, i right click the text, and click view image, it then gives me the 404.php page all blank. so basically i understand that it's not poiting to the gif anymore, but i dunno why it is not showing the png file then? any idea?

Zachery
07-18-2008, 11:58 AM
A link to your site would be useful :)

pranaysanghavi
07-19-2008, 07:51 PM
Edit htaccess file to give a full/proper url to your new 404.php

kindly explain proper steps in layman's terms...

u mean we shud create new htaccess and new 404.php, both of which we shud load in image dir of every style that our forum has?

Zachery
07-20-2008, 01:45 PM
Its explained as simply as possible.

pranaysanghavi
07-22-2008, 10:33 AM
Its explained as simply as possible.

hmm didnt work as expected. please open in IE-> http://www.officechai.com/testvbforum/index.php
see the empty image placeholders (scroll down) in main forum categories (not the header) on that very page..

I put the 404.php and .htaccess in here:
/public_html/testvbforum/images

i had some images in png, and not gif, same file name.. however, it still doesn't auto replace it. [i even changed the template to refer to .png] it still looks for testvbforum/images/styles/smartblue/statusicon/forum_old.gif but i do have testvbforum/images/styles/smartblue/statusicon/forum_old.png there.

i checked with my hostmonster guy, they do support this. any help appreciated.

StGaensler
07-22-2008, 11:23 AM
Not Found

The requested URL /testvbforum/images/styles/smartblue/statusicon/forum_old.gif was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

Apache/2.2.9 (Unix) mod_ssl/2.2.9 OpenSSL/0.9.8g DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 Server at www.officechai.com Port 80The server can't find the ErrorDocument - the 404.php
Give him the correct path to this file, and he will find it.

pranaysanghavi
07-25-2008, 05:16 PM
The server can't find the ErrorDocument - the 404.php
Give him the correct path to this file, and he will find it.

How to give the correct path? sorry to trouble with silly questions, but i still can't get it working. this is the final mod that I need to configure, apart from one unrelated, before i could go live.

I've put .htaccess at 3, 4 places in the dir structure. where all shud i put 404 and where all shud i put .htaccess?

I'm new to .htaccess and php, as per the instruction I've added the files. still i dont see any result. can u please guide me little easy? :erm:

gezuvor
08-21-2008, 05:55 PM
My server can find the 404 file, but it's just showing a blank page... ?

dannykilla
09-02-2008, 10:49 PM
Hi Zachery,

I have now uploaded the .htaccess & 404.php file to the /images/ directory and give the full path to the 404.php file on the .htaccess and also uploaded a newthread.png and removed the newthread.gif img.

but I dont get the png image I just get text, I sent you a PM with my URL.

Thanks m8
Dan

Konstantinos
09-03-2008, 02:57 PM
why using this while we can use replacement variables if we want to have both png and gif
/buttons/newreply.gif -> /buttons/newreply.png

apart from having to add each replacement variable for every png we intend to use, is there any other benefit ?

Zachery
09-03-2008, 04:54 PM
why using this while we can use replacement variables if we want to have both png and gif
/buttons/newreply.gif -> /buttons/newreply.png

apart from having to add each replacement variable for every png we intend to use, is there any other benefit ?
It'd be _alot_ of replacements, i'd rather not write that much code tbh.

Zachery
09-03-2008, 04:56 PM
http://www.tf2-forums.co.uk/forums/images/buttons/newthread.png redirects to >
http://www.tf2-forums.co.uk/forums/images/404.php But doesn't redirect.

Make sure your php error reporting is on.

dannykilla
09-03-2008, 06:16 PM
I have spoken to my host and they say that error reporting is ON by default.
But said that this on the support ticket:

"Dan,

Error reporting is enabled for the server by default. This would only change if you created a php.ini file that disabled it or the script itself disabled it. Have you checked the directory where the script resides to see if an error_log file is being created?"

So what I think he is referring to vBulletin, does vB do this ?

Dan

dannykilla
09-04-2008, 07:34 AM
Now my server is using PHP 5, I have error reporting switched ON. Is there any thing you can think of that may be causing me to have trouble with this hack?

Thanks
Danny

dannykilla
09-04-2008, 04:12 PM
I have figured this out now, thanks to StGaensler!

I was putting the full URL path on the .htaccess file instead of simply putting this:

ErrorDocument 404 /forums/images/404.php

Thanks Zachery Awesome hack and thanks StGaensler!
Dan

killswitch
10-12-2008, 01:14 PM
Terrible... won't work with easyPhP.

Zachery
10-13-2008, 06:57 AM
What?

eJM
10-29-2008, 05:34 AM
You can easily rename a .png to a .gif and have the .png display normally in all major browsers.

No need for this hack.

You shouldn't though.

Why shouldn't we? I was just having trouble with 7 icons in the statusicon folder. I use Fireworks for my graphics work, so I created the images in PNG8 with drop-shadows. GIF transparencies just weren't making the cut. Anyway, I uploaded the PNG files and then renamed them to GIF files. Works great - a lot better than the transparent GIFs, although file size was increased.

I'm waiting to hear back from some of my older members to see if they think they render different than they should. Some of them might be using older versions of their browsers.

R'gards,

Jim McClain

dannykilla
12-17-2008, 09:49 PM
anyone else get this working on 3.8 RC1 ?

Zachery
12-23-2008, 07:56 AM
Danny, this in theory works anywhere, it has no real version depedancy. Infact it can work on non vbulletin sites just as well.

tommythejoat
01-22-2009, 03:35 PM
In short the feature only requires Apache.

I think the not found option in the alternate form is easy to overlook when reading.

If you use the mod rewrite you save a file fetch and an execution. If you are loading the simley images, the editor, etc. that is a lot of reads. Offhand it looks like it would save about 100 or so file reads per page.

NAZIA
03-19-2009, 02:57 PM
I can not understand, why you prefer PNG....

here in IE6 Png are creating problem, in transparency, you can see
screen shot..
96722
96721

But Gif never shows this dual effect...

Zachery
03-21-2009, 06:21 PM
I can not understand, why you prefer PNG....

here in IE6 Png are creating problem, in transparency, you can see
screen shot..
96722
96721


But Gif never shows this dual effect...



Because IE6 sucks, its a bad browser with limited support. PNG's have alpha transparency which is better than normal on off transparency. All modern browsers support PNG's.

StGaensler
03-23-2009, 01:04 PM
I can not understand, why you prefer PNG....

here in IE6 Png are creating problem, in transparency, you can see
screen shot..
I can't understand why you prefer a more than seven-year-old browser over a modern webbrowser :) IE 6 was released in october 2001...

stanleys
04-02-2009, 01:07 AM
This mod works by redirecting all forum icon requests to their .png equivalent via mod_rewrite?

daCocio
04-05-2009, 04:10 AM
It was working but I made a few icon changes, now it does not work. I redid everything when it first worked. I am just puzzled. Any thoughts? You can see the missing images mostly on the postbit & thread page.

My site: http://tinyurl.com/d4u49l

dannykilla
04-25-2009, 03:13 PM
Hi,

I have recently tried to get this to work on my server and for some reason its not having it, so I tried the same process on my friends server and it worked, so what could be stopping it on my end.

When I delete the .gifs all I get is a blacnk space on FF!

Can anyone suggest anything?

thanks
Danny

dannykilla
04-27-2009, 10:11 PM
Ok I have spoken to one of the Tech dudes from my hosts and he said this:

"This hack will not work in your configuration as any file that does not exist (which would cause a 404) will be handed to Wordpress and managed by wordpress' 404 handler."

Is there anyway around this?

Dan

dannykilla
04-28-2009, 10:54 AM
My hosts re-wrote my Wordpress .htaccess file, and this now works awesome!

If anyone uses Wordpress and wants to know how to solve this, just send me a PM.

Carlos-Sz
06-01-2009, 09:42 PM
I have two things to remark:

As you send a Location: header the Content-type: header doesn't matter as the browser makes a second request for the png file.

This second request takes some time so I suggest doing the "decision" directly on the server without the need of a second request. This only needs the Apache module mod_rewrite:RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*)\.gif$ $1.png [NC,L]Every non-existing gif file so gets redirected to a png file. I don't check if the png file exists but I think this doesn't matter ;)

Stefan

Can you please explain a bit more?

Do I have to add those lines in my ".htaccess" file? Is that all?

In my root folder I can't see any mod_rewrite. I'm sorry but I know nothing about this.

Thank you in advance.