Advertisement:

Author Topic: Transparent PNGs for IE BBCode  (Read 27331 times)

Offline Kirby

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 2,040
  • Gender: Male
Transparent PNGs for IE BBCode
« 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:
Code: [Select]
$codefromcache = array_keys($code_to_from);
$codetocache = array_values($code_to_from);


Add directly after:
Code: [Select]
// 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
« Last Edit: May 21, 2005, 02:00:38 AM by Kirby »

Offline Jerry

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 2,903
  • Gender: Male
  • What? I can't hear you over my awesomeness!!
    • PlanetSMF
Re: Transparent PNGs for IE BBCode
« Reply #1 on: May 21, 2005, 04:02:45 AM »
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."

Offline Kirby

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 2,040
  • Gender: Male
Re: Transparent PNGs for IE BBCode
« Reply #2 on: May 21, 2005, 02:51:18 PM »
yeah, its pretty intensive..

Offline Waste

  • Jr. Member
  • **
  • Posts: 179
  • Gender: Male
  • Eh?
    • http://www.theunderside.org/
Re: Transparent PNGs for IE BBCode
« Reply #3 on: June 16, 2005, 04:33:41 PM »
I take it this doesn't work on SMF 1.0.2?

Offline Kirby

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 2,040
  • Gender: Male
Re: Transparent PNGs for IE BBCode
« Reply #4 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

Offline dtm.exe

  • SMF Hero
  • ******
  • Posts: 5,465
Re: Transparent PNGs for IE BBCode
« Reply #5 on: June 16, 2005, 08:13:51 PM »
Great trick :).

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

-Dan The Man

Offline Waste

  • Jr. Member
  • **
  • Posts: 179
  • Gender: Male
  • Eh?
    • http://www.theunderside.org/
Re: Transparent PNGs for IE BBCode
« Reply #6 on: June 17, 2005, 02:49:24 AM »
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:

Code: [Select]
$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

« Last Edit: June 17, 2005, 03:11:48 AM by Waste »

Offline Lithriel

  • Semi-Newbie
  • *
  • Posts: 69
Re: Transparent PNGs for IE BBCode
« Reply #7 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.

Code: [Select]
$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

Offline Antechinus

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 24,136
  • Master of BBC Abuse
Re: Transparent PNGs for IE BBCode
« Reply #8 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.

Offline alegz

  • Newbie
  • *
  • Posts: 3
Re: Transparent PNGs for IE BBCode
« Reply #9 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. :)

Offline alegz

  • Newbie
  • *
  • Posts: 3
Re: Transparent PNGs for IE BBCode
« Reply #10 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. :)

Offline alegz

  • Newbie
  • *
  • Posts: 3
Re: Transparent PNGs for IE BBCode
« Reply #11 on: June 25, 2009, 06:43:25 AM »
Problem solved. :)
This function located in file /Sources/Subs.php

:)