Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 02-02-2004, 08:32 PM
gmarik's Avatar
gmarik gmarik is offline
 
Join Date: May 2002
Location: Mocsow
Posts: 1,288
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default PNG Alpha Transparency

Is this good enough? http://www.koivi.com/ie-png-transparency/

PHP Code:
<?php
/*
* replacePngTags - Justin Koivisto [W.A. Fisher Interactive] 7/1/2003 10:45AM
*
* Modifies IMG tags for MSIE5+ browsers to ensure that PNG-24 transparencies
* are displayed correctly. Replaces original SRC attribute with a transparent
* GIF file (spacer.gif) that is located in the same directory as the orignal
* image, and adds the STYLE attribute needed to for the browser. (Matching
* is case-insensitive.
*
* @param $x String containing the content to search and replace in.
* @result Returns the modified string.
*/
function replacePngTags($x){
    
// make sure that we are only replacing for the Windows versions of Internet 
    // Explorer 5+, and not Opera identified as MSIE 
    
$msie='/msie\s([5-9])\.?[0-9]*.*(win)/i'
    
$opera='/opera\s+[0-9]+/i'
    if(!isset(
$_SERVER['HTTP_USER_AGENT']) || 
        !
preg_match($msie,$_SERVER['HTTP_USER_AGENT']) || 
        
preg_match($opera,$_SERVER['HTTP_USER_AGENT'])) 
        return 
$x
 
    
// OK, time to find all the IMG tags with ".png" in them
    
preg_match_all('/<img.*\.png.*>/Ui',$x,$images);
    while(list(
$imgnum,$v)=@each($images[0])){
        
$original=$v;
        
$atts=''$width=0$height=0;
        
// If the size is defined by styles, find 
        
preg_match_all('/style=".*(width: ([0-9]+))px.*'.
                        
'(height: ([0-9]+))px.*"/Ui',$v,$arr2);
        if(
is_array($arr2) && count($arr2[0])){
            
// size was defined by styles, get values
            
$width=$arr2[2][0];
            
$height=$arr2[4][0];
        }
        
// size was not defined by styles, get values
        
preg_match_all('/width=\"?([0-9]+)\"?/i',$v,$arr2);
        if(
is_array($arr2) && count($arr2[0])){
            
$width=$arr2[1][0];
        }
        
preg_match_all('/height=\"?([0-9]+)\"?/i',$v,$arr2);
        if(
is_array($arr2) && count($arr2[0])){
            
$height=$arr2[1][0];
        }
        
preg_match_all('/src=\"([^\"]+\.png)\"/i',$v,$arr2);
        if(isset(
$arr2[1][0]) && !empty($arr2[1][0]))
            
$image=$arr2[1][0];
        else
            
$image=NULL;
 
        
// We do this so that we can put our spacer.gif image in the same
        // directory as the image
        
$tmp=split('[\\/]',$image);
        
array_pop($tmp);
        
$image_path=join('/',$tmp);
        if(
strlen($image_path)) $image_path.='/';
 
        
// end quote is already supplied by originial src attribute
        
$replace_src_with=$image_path.'spacer.gif" style="width: '.$width.
            
'px; height: '.$height.'px; filter: progidXImageTransform.'.
            
'Microsoft.AlphaImageLoader(src=\''.$image.'\', sizingMethod='.
            
'\'scale\')';
 
        
// now create the new tag from the old
        
$new_tag=str_replace($image,$replace_src_with,$original);
 
        
// now place the new tag into the content
        
$x=str_replace($original,$new_tag,$x);
    }
    return 
$x;
}
?>
Reply With Quote
  #2  
Old 02-03-2004, 08:32 AM
KuraFire's Avatar
KuraFire KuraFire is offline
 
Join Date: Oct 2001
Location: inside vB3's .php
Posts: 1,245
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

you may wanna remove the whole quoted function and try to re-paste it using a standard or basic editor interface - the WYSIWYG f\/cks it up big time...
Reply With Quote
  #3  
Old 02-03-2004, 01:42 PM
assassingod's Avatar
assassingod assassingod is offline
 
Join Date: Jul 2002
Posts: 3,337
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Fixed
Reply With Quote
  #4  
Old 02-03-2004, 02:25 PM
gmarik's Avatar
gmarik gmarik is offline
 
Join Date: May 2002
Location: Mocsow
Posts: 1,288
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks. So I save it as the alpha.php file.
How do I require it in the vBulletin options?
Reply With Quote
  #5  
Old 02-03-2004, 07:19 PM
Natch's Avatar
Natch Natch is offline
 
Join Date: Nov 2002
Location: Australia
Posts: 851
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OMG Thanks!
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:45 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03960 seconds
  • Memory Usage 2,229KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (5)post_thanks_box
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (5)post_thanks_postbit_info
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete