News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

useron.gif and useroff.gif to PNG

Started by Belisarius, July 14, 2013, 09:18:13 AM

Previous topic - Next topic

Belisarius

Hi, it's me again.

I want to change the useron and useroff.gif to PNG file formats for better looks, but I can't find the template file in which I need to change the file extension. Anyone care to help? No matter where I look I find no hints for these two images.

I'm using a custom theme called darkmodern202 which I customized myself a bit to fit the purpose of my LotRo forum. But within this theme I also haven't found any hints of these two files.

Illori

it can not be configured per theme.

Code (load.php) Select
'image_href' => $settings['images_url'] . '/' . ($profile['buddy'] ? 'buddy_' : '') . ($profile['is_online'] ? 'useron' : 'useroff') . '.gif',

butch2k

Note that browsers do not rely on extension to determine image format, save the files as PNG but with a filename ending by .gif, it will do the trick if you do not want to touch the code.

Belisarius

Quote from: Illori on July 14, 2013, 09:25:31 AM
it can not be configured per theme.

Code (load.php) Select
'image_href' => $settings['images_url'] . '/' . ($profile['buddy'] ? 'buddy_' : '') . ($profile['is_online'] ? 'useron' : 'useroff') . '.gif',

Where do I have to look for that?

Chalky


Belisarius


MrPhil

Quote from: butch2k on July 14, 2013, 09:39:44 AM
Note that browsers do not rely on extension to determine image format, save the files as PNG but with a filename ending by .gif, it will do the trick if you do not want to touch the code.

Is that universally true? I've never heard of that. I can imagine some browsers allowing that (look inside the file to figure out its format), but I've never seen this as recommended behavior. Can you guarantee that this will always work on all browsers?

butch2k

I'm not saying it's recommended but yes it will work on all browsers i know of, in IE6 you won't get transparency though but that's to be expected...

ARG01

Quote from: butch2k on July 14, 2013, 09:39:44 AM
Note that browsers do not rely on extension to determine image format, save the files as PNG but with a filename ending by .gif, it will do the trick if you do not want to touch the code.


I've never heard of that either but if that is the case, It's still better to have the file extension the same as the image. It's only logical to not make a browser work more than it needs to. 

Btw, I have tried your method and it does not seem to work in my latest version of FF.  :-\
No, I will not offer free downloads to Premium DzinerStuido themes. Please stop asking.

Phil De Quincy

Hi Amua,

You're "-utf8"

There is a special way of getting useroff.gif but i'm not sure what the special way.

Anyway, when this is figured out let me know. Thanks.

Phil.
I GET NO DOUBT!!! Freak ya.

Illori

this has been figured out already if you read the whole thread.

Belisarius

My board isn't UTF8 and it didn't work either for me in FF 22.0, so I made it the way it's recommended.

Chalky

Quote from: Belisarius on July 14, 2013, 03:26:17 PM
My board isn't UTF8 and it didn't work either for me in FF 22.0, so I made it the way it's recommended.

I don't think anyone who has posted on this topic is call Amua either  ;)

butch2k

Quote from: ARG on July 14, 2013, 12:40:22 PM
Quote from: butch2k on July 14, 2013, 09:39:44 AM
Note that browsers do not rely on extension to determine image format, save the files as PNG but with a filename ending by .gif, it will do the trick if you do not want to touch the code.


I've never heard of that either but if that is the case, It's still better to have the file extension the same as the image. It's only logical to not make a browser work more than it needs to. 

Btw, I have tried your method and it does not seem to work in my latest version of FF.  :-\
Browsers as most correctly designed software use magic numbers not extensions to determine image's type ;)
If they used extensions, dynamic image scripts would not work for instance. Think of signature.php scripts and the like which send the image data dynamicaly.

This method definitely works in FF 22.

MrPhil

Why then do they bother with a filetype (extension)? Is this a leftover from DOS days? I would think that the programmers (not necessarily the software) would get awfully confused with arbitrary (or no) extensions on files. Any text file (source) would have to have an extension (.c, .php, .css, .txt, etc.) anyway, so is there any real advantage to not having a proper extension on image files? As for a dynamic image script (.php), the server is going to send that data with non-filename/extension information anyway.

Kindred

well, I know that most Operating systems won't be able to assign the correct program to handle a file without the extension, so it sounds like this is just a browser thing.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

ARG01

QuoteNote that browsers do not rely on extension to determine image format, save the files as PNG but with a filename ending by .gif, it will do the trick if you do not want to touch the code.

QuoteBrowsers as most correctly designed software use magic numbers not extensions to determine image's type ;)
If they used extensions, dynamic image scripts would not work for instance. Think of signature.php scripts and the like which send the image data dynamicaly.

This method definitely works in FF 22.


I am also using FF 22. It may be possible that I am not completely understanding your logic.  As a test and as I have done many times before, using Photoshop I changed the default info.gif and online.gif images to png format. I was not at all surprised when they suddenly vanished and did not reappear until I changed the file extensions in the code to match. Same results with IE and Chrome.

What am I missing or not understanding here?
No, I will not offer free downloads to Premium DzinerStuido themes. Please stop asking.

MrPhil

PNG format with .gif extension? According to @butch2k, that should work, but maybe it takes some setting in the browser? I don't really see the advantage to doing that, other than you can get lazy about extensions (and maybe slip in something malicious while you're at it?).

Kindred

actually, IIRC, that was the vector of an attack, a while ago...   have a php file named as GIF, but executed when "viewed"
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

ARG01

Quote from: MrPhil on July 15, 2013, 01:19:56 PM
PNG format with .gif extension? According to @butch2k, that should work, but maybe it takes some setting in the browser? I don't really see the advantage to doing that, other than you can get lazy about extensions (and maybe slip in something malicious while you're at it?).

So in this case, would one have to add a disclaimer for all visitors to adjust their browser settings?  :D

I am sure that using a file extension different from an image extension would not play well with those that prefer proper code validation.

Either way, I see neither any sort of advantage or true logic in attempting this. Other than pure laziness, it just doesn't make sense to purposely have different extensions when altering code or an image is so simple to begin with.
No, I will not offer free downloads to Premium DzinerStuido themes. Please stop asking.

butch2k

There are several cases in SMF where it's not so easy to change extension (smilies anyone ?), but here indeed it was fairly easy (at least apparently so as mods might be an issue... IIRC UltimateProfile use useron.gif somewhere in the template file for instance). I provided this quick and dirty fix as the original poster seemed reluctant to edit the code, but i never said i recommended it.

You can see a PNG disguised as a GIF here: http://planeteroliste.com/files/www_sm.gif and no your browser won't scream and burn... ;)

The way file type is handled by browsers is related to both the mime type sent by the server and the file's magic number, and hopefully so else script such as this one: http://www.simplemachines.org/community/index.php?topic=505444.0 would never work (a .php image file !!!!  ::)  ;) ) .

@Kindred
it's not really the same issue, it's a .php.gif issue related to the way filename could be parsed server's end.

ARG01

I can see your point but I guess I am just one of those that prefer to keep things proper. If I knew that somewhere in my files was a gif being handled as a png, sooner or later it would drive me nuts and I would have to fix it.  :D

That said, replacing gif images with png's and adjusting the code to suit is quite easy no matter where the image resides. Three times now I have converted SMF to 100% png and ousted all gif's. This included both file and image alterations. Sure it's very time consuming but it can be done.  ;)
No, I will not offer free downloads to Premium DzinerStuido themes. Please stop asking.

Belisarius

Proper site management and coding is the reason for me asking here for help and not trying out some random hacks that might work, but can cause trouble under certain circumstances. I don't want to say that just creating a PNG icon with gif extension is a bad idea, but it's just the way ARG explained. It's not what I consider "proper".

Advertisement: