The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
vB Integration of "Normal display of PNG Alpha Transparency with MSIE" PHP script Details »» | |||||||||||||||||||||||||||
vB Integration of "Normal display of PNG Alpha Transparency with MSIE" PHP script
Developer Last Online: Apr 2022
File Edits: 2 (in one file)
New Files: 1 (forumroot/images/spacer.png) This script, for those that don't know it, is a server-side solution to the faulty display of 24-bit alpha transparencies in MSIE... For more info please read up on the site created by the d00d that wrote the script - all the props go to him! Created in response to my need to bloody well get it right after so many months, as well as https://vborg.vbsupport.ru/showthread.php?t=61091 and https://vborg.vbsupport.ru/showthread.php?t=66846... OK - now to get this integrated to your vB so that any PNG24 images with transparency will display without that ugly grey backdrop in MSIE, please do the following: In includes/functions.php: Find: PHP Code:
PHP Code:
PHP Code:
PHP Code:
PHP Code:
OK - now the only reason this will not work (except if you neglect to upload this excellent functions.php file) is if your calls to the PNG file of your choice does not have a full definition ... When I say work - your forum will still work no probs, it's just the script will pass over each PNG tag like the Angel of Death over a blood-stained door if you don't fit the bill Will work: <img src="$vboptions[bburl]/images/misc/someimage.png" width="10" height="10" /> Will not work: <img src="$vboptions[bburl]/images/misc/someimage.png" /> Will work: <img src="clear.gif" style="background-image:url($vboptions[bburl]/images/misc/someimage.png);height:10px;width:10px" /> Will not work: <img src="clear.gif" style="background-image:url($vboptions[bburl]/images/misc/someimage.png)" /> Will work: <body style="background-image:url($vboptions[bburl]/images/misc/someimage.png)"> Read over his page if you want more info as I said Enjoy y'all ( and please remember to test this in IE - it will only make a difference if you use IE ) I've also attached for your own testing, the same image used in the test on the original author's site... Have fun kiddies May the PNG24 be with you LOL - well that attachment of the spacer.png doesn't work ;D you need to be able to see the 1x1 attachment to click on it hehe... feel free to grab it from http://www.mobileforces.org/forums/images/spacer.png EDIT 26-08-2004: This links to a HOW-TO on using this with Avatars - it requires a small one-file, one-tempalte hack. EDIT: 07-01-2005 The function this is based on was updated a while back to NOT require the width and height to be explicitly defined, and so this has now been updated to include the latest version of this function. TO UPGRADE: Just replace: PHP Code:
PHP Code:
Supporters / CoAuthors Show Your Support
|
Comments |
#32
|
|||
|
|||
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/ |
#33
|
||||
|
||||
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.
|
#34
|
||||
|
||||
Let me be the first to thank you for the update. I'll try to see where i was wrong.
Thank you |
#35
|
||||
|
||||
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.
|
#36
|
||||
|
||||
Neither version works for me, using 3.0.6..
|
#37
|
|||
|
|||
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??? |
#38
|
||||
|
||||
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 |
#39
|
|||
|
|||
Thanx that worked a treat!!!!
Only i have png images in the postbit under the username and the grey area still shows on those?? |
#40
|
||||
|
||||
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.
|
#41
|
||||
|
||||
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. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|