vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.0 Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=33)
-   -   vB Integration of "Normal display of PNG Alpha Transparency with MSIE" PHP script (https://vborg.vbsupport.ru/showthread.php?t=67413)

Andaas 09-23-2004 02:58 AM

Looking forward to adding this to my site, though a friend pointed me at another solution that I thought I would share. Not sure how easy/hard this would be to use with vBulletin is all.

Check out http://www.mongus.net/pngInfo/

Natch 01-07-2005 03:10 AM

This has been updated today to include the latest version of this function: now no longer requires the width / height to be explicitly defined for it to pck up on the PNG images and make modifications if required.

cclaerhout 01-07-2005 05:24 AM

Let me be the first to thank you for the update. I'll try to see where i was wrong.

Thank you ;)

cclaerhout 01-08-2005 10:25 AM

Well, i've tested this new version, and it doesn't work for me... And it slows down my website on IE... So it've put your "old" hack.

Oblivion Knight 01-30-2005 01:53 PM

Neither version works for me, using 3.0.6.. :(

KuRi 02-07-2005 09:17 PM

I followed this exactly... but when a page is viwed with my png quotes on it i get
Warning: getimagesize(): Read error! in /includes/functions.php on line 4013

Warning: getimagesize(): Read error! in /includes/functions.php on line 4013

Warning: getimagesize(): Read error! in /includes/functions.php on line 4013
at the top of the page and none of the png's show.... any clues???

cclaerhout 02-08-2005 02:30 PM

I understand ! Natch has updated his first version of his hack.

Here is the old one :

Code:

// PNG-24 Alpha Transparency with MSIE
/* ***
* replacePngTags - Justin Koivisto [W.A. Fisher Interactive] 7/1/2003 10:45AM
* function to IE display of PNG transparencies - integrated to vB3 by Natch@mobileforces.org
* *** */
function replacePngTags($x,$img_path='/forum/images/')
{
        $arr2=array();
        // make sure that we are only replacing for the Windows versions of Internet
        // Explorer 5+
        $msie='/msie\s([5-9])\.?[0-9]*.*(win)/i';
        if(!isset($_SERVER['HTTP_USER_AGENT']) ||
                !preg_match($msie,$_SERVER['HTTP_USER_AGENT']) ||
                preg_match('/opera/i',$_SERVER['HTTP_USER_AGENT']))
                return $x;

        // find all the png images in backgrounds
        preg_match_all('/background-image:\s*url\(\'(.*\.png)\'\);/Uis',$x,$background);
        for($i=0;$i<count($background[0]);$i++){
                // simply replace:
                //  "background-image: url('image.png');"
                // with:
                //  "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(
                //      enabled=true, sizingMethod=scale src='image.png');"
                // haven't tested to see if background-repeat styles work...
                $x=str_replace($background[0][$i],'filter:progid:DXImageTransform.'.
                        'Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale'.
                        ' src=\''.$background[1][$i].'\');',$x);
        }

        // OK, time to find all the IMG tags with ".png" in them
        $pattern='/<(input|img)[^>]*src=(\\\'|\\")([^>]*\.png)\2[^>]*>/i';
        preg_match_all($pattern,$x,$images);
        for($num_images=0;$num_images<count($images[0]);$num_images++){
                $original=$images[0][$num_images];
                $quote=$images[2][$num_images];
                $atts=''; $width=0; $height=0; $modified=$original;

                // If the size is defined by styles, find them
                preg_match_all(
                        '/style=(\\\'|\\").*(\s?width:\s?([0-9]+(px|%));).*'.
                        '(\s?height:\s?([0-9]+(px|%));).*\\1/Ui',
                        $images[0][$num_images],$arr2);
                if(is_array($arr2) && count($arr2[0])){
                        // size was defined by styles, get values
                        $width=$arr2[3][0];
                        $height=$arr2[6][0];

                        // remove the width and height from the style
                        $stripper=str_replace(' ','\s','/('.$arr2[2][0].'|'.$arr2[5][0].')/');
                        // Also remove any empty style tags
                        $modified=preg_replace(
                                '`style='.$arr2[1][0].$arr2[1][0].'`i',
                                '',
                                preg_replace($stripper,'',$modified));
                }

                // size was not defined by styles, get values from attributes
                preg_match_all('/width=(\\\'|\\")?([0-9%]+)\\1/i',$images[0][$num_images],$arr2);
                if(is_array($arr2) && count($arr2[0])){
                        $width=$arr2[2][0];
                        if(is_numeric($width))
                                $width.='px';

                        // remove this from the tag
                        $modified=str_replace($arr2[0][0],'',$modified);
                }
                preg_match_all('/height=(\\\'|\\")?([0-9%]+)\\1?/i',$images[0][$num_images],$arr2);
                if(is_array($arr2) && count($arr2[0])){
                        $height=$arr2[2][0];
                        if(is_numeric($height))
                                $height.='px';

                        // remove this from the tag
                        $modified=str_replace($arr2[0][0],'',$modified);
                }

                // if either height or width were left out, son't replace this image this allows
                // the image to show up (not fixed) instead of not displaying the image at all
                if($width==0 || $height==0)
                        continue;

                preg_match_all('/src=(\\\'|\\")([^\"]+\.png)\\1/i',$images[0][$num_images],$arr2);
                if(isset($arr2[2][0]) && !empty($arr2[1][0]))
                        $image=$arr2[2][0];
                else
                        $image=NULL;

                if(!empty($img_path)){
                        // We do this so that we can put our spacer.png image in the same
                        // directory as the image
                        $tmp=split('[\\/]',$image);
                        array_pop($tmp);
                        $img_path=join('/',$tmp);
                        if(strlen($img_path)) $img_path.='/';
                }

                // end quote is already supplied by originial src attribute
                $replace_src_with=$img_path.'spacer.png'.$quote.' style="width: '.$width.
                        '; height: '.$height.'; filter: progid:DXImageTransform.'.
                        'Microsoft.AlphaImageLoader(src=\''.$image.'\', sizingMethod='.
                        '\'scale\');"';

                // now create the new tag from the old
                $new_tag=str_replace($image.$quote,$replace_src_with,
                        str_replace('  ',' ',$modified));
                // now place the new tag into the content
                $x=str_replace($original,$new_tag,$x);
                $i++;
        }
        return $x;
}
// /PNG-24 Alpha Transparency with MSIE


KuRi 02-08-2005 08:54 PM

Thanx that worked a treat!!!!

Only i have png images in the postbit under the username and the grey area still shows on those??

Bad Bunny 02-15-2005 03:22 PM

Well. I could not get pngs with transparent alpha layers to show properly as a background image. The hack worked great for regular images. So...I finally upgraded to the new version. And you know what? Still doesn't work with background images...and now if a png image doesn't have height and width it just doesn't display in IE for windows. It's odd...cause before, it would just show the grey background, but now the image disapears altogether.

cclaerhout 03-03-2005 01:00 PM

Justin Koivisto released the 25 february 2005 the 2.06 version of his script and guess what... It works :-) Except that the width and height still must be precised otherwise no image appears.

The new code is joined in the attache text file.


All times are GMT. The time now is 05:04 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05429 seconds
  • Memory Usage 1,769KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete