Transparent PNGs for IE BBCode

Started by Kirby, May 21, 2005, 12:57:03 AM

Previous topic - Next topic

Kirby

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

Jerry

yikes... that page made my internet explorer lock up, and eventually my pc...


- Jerry
Find me on:
Facebook
Twitter
PlanetSMF

"If all you look for is the negative in things, you will never see the positive."

Kirby


Waste

I take it this doesn't work on SMF 1.0.2?

Kirby

it should...
the only version i know of that it wont work on yet is 1.1 beta 3

dtm.exe

Great trick :).

* OIDanTheManIO gives IE the evil eye for not making my precious Opera avatar transparent...

-Dan The Man

Waste

#6
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


Lithriel

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

Antechinus

Or you can use css to feed a png-8 or a gif for IE6. AlplhaImageLoader is nasty no matter how you do it.

alegz

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. :)

alegz

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. :)

alegz

Problem solved. :)
This function located in file /Sources/Subs.php

:)

Advertisement: