Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Topic started by: Kirby on May 21, 2005, 12:57:03 AM

Title: Transparent PNGs for IE BBCode
Post by: Kirby on May 21, 2005, 12:57:03 AM
What it does
Makes IE use DirectX to properly render PNGs with transparency.

How to apply
Open: Sources/Subs.php

Look for:

$codefromcache = array_keys($code_to_from);
$codetocache = array_values($code_to_from);



Add directly after:

// A PNG image with transparency in IE5.5+. Maybe not the best solution, but it works :P.  Width and height are optional.
$codefromcache[] = '~\[png(\s+width=([\d]+))?(\s+height=([\d]+))?\s*\](?:<br />)*(.+?)(?:<br />)*\[/png\]~ei';
if (isset($disabled['png']) || isset($disabled['img']))
$codetocache[] = '$5';
elseif ($context['browser']['is_ie5.5'] || $context['browser']['is_ie6'])
$codetocache[] = '\'<a href="$5"><img src="' . $settings['images_url'] . '/blank.gif" alt=""\' . (\'$2\' != \'\' ? \' width="$2"\' : \'\') . (\'$4\' != \'\' ? \' height="$4"\' : \'\') . \' border="0" style="filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=\\\'true\\\', src=\\\'$5\\\', sizingMethod=\\\'\' . (\'$2\' != \'\' || \'$4\' != \'\' ? \'scale\' : \'image\') . \'\\\');" /></a>\'';
else
$codetocache[] = '\'<img src="$5" alt=""\' . (\'$2\' != \'\' ? \' width="$2"\' : \'\') . (\'$4\' != \'\' ? \' height="$4"\' : \'\') . \' border="0" />\'';


Other Resources
http://koivi.com/ie-png-transparency/

Usage
[png]http://blah.com/blah.png[/png]
[png=http://blah.com/blah.png (optional: width=20 height=20)]blahblah[/png]
In other words, same as the [img] tag.

Enjoy ;D
Title: Re: Transparent PNGs for IE BBCode
Post by: Jerry on May 21, 2005, 04:02:45 AM
yikes... that page made my internet explorer lock up, and eventually my pc...
Title: Re: Transparent PNGs for IE BBCode
Post by: Kirby on May 21, 2005, 02:51:18 PM
yeah, its pretty intensive..
Title: Re: Transparent PNGs for IE BBCode
Post by: Waste on June 16, 2005, 04:33:41 PM
I take it this doesn't work on SMF 1.0.2?
Title: Re: Transparent PNGs for IE BBCode
Post by: Kirby on June 16, 2005, 08:05:09 PM
it should...
the only version i know of that it wont work on yet is 1.1 beta 3
Title: Re: Transparent PNGs for IE BBCode
Post by: dtm.exe on June 16, 2005, 08:13:51 PM
Great trick :).

/me gives IE the evil eye for not making my precious Opera avatar transparent...

-Dan The Man
Title: Re: Transparent PNGs for IE BBCode
Post by: Waste on June 17, 2005, 02:49:24 AM
Quote from: ??? on June 16, 2005, 08:05:09 PM
it should...
the only version i know of that it wont work on yet is 1.1 beta 3

Well, I couldn't find these lines of code anywhere in Subs.php:

$codefromcache = array_keys($code_to_from);
$codetocache = array_values($code_to_from);


Wait, nevermind.
This doesn't even do what I want.
I have a piece of code that enables PNGs anywhere on the site to become transparent when viewed with IE.
Problem is, it gives me parse errors when I use it.
Even when the quotes that create the parse errors are escaped.
If I post the code, do you think you might be able to fix the parse errors?

I got it fixed. :D

Title: Re: Transparent PNGs for IE BBCode
Post by: Lithriel on May 15, 2009, 10:24:58 AM
Sorry for necro posting, but I too am not able to find the following code in subs.php.

$codefromcache = array_keys($code_to_from);
$codetocache = array_values($code_to_from);


So where should I post this?  I am using a custom theme with SMF 1.1.8
Title: Re: Transparent PNGs for IE BBCode
Post by: Antechinus on June 17, 2009, 10:15:18 PM
Or you can use css to feed a png-8 or a gif for IE6. AlplhaImageLoader is nasty no matter how you do it.
Title: Re: Transparent PNGs for IE BBCode
Post by: alegz on June 25, 2009, 05:52:43 AM
Hi to everebody.
I didn't want to create an additional theme that's why I'll ask my question here.
For one project I want to make some integration of 2 web application. The idea is:
I have a web site that shows the news of the comunity. Also I have a board with news in order not to publish one news twice through 2 application I want to make first messages of board news be displayed on web site.
This task was done. But I stucked with problem of BB codes. I don't want to make an additional BB code parser or use any. I want to use BB code parser that is in SMF forum engine. May be someone knows what file contains this function. It would be perfect if you could also tell the name of function that parses BB codes in forum. :)

Thank you for attention. :)
Title: Re: Transparent PNGs for IE BBCode
Post by: alegz on June 25, 2009, 06:23:31 AM
Spending some time I found out that function parse_bbc does BB code parsing. Last question where this function located?

I think if I'll spend some a little bit more time I'll answear this question by myself. :)
Title: Re: Transparent PNGs for IE BBCode
Post by: alegz on June 25, 2009, 06:43:25 AM
Problem solved. :)
This function located in file /Sources/Subs.php

:)