pngfix Wordpress Plugin

May 9th, 2008 | By Taha Paksu

This plugin uses CSS technique to fix the png image transparency issue and jQuery to apply this script to all of png images shown in the page. The CSS code added by the script is :

.png {
background-image: expression(
this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=" + (this.tagName==\'IMG\' ? this[\'src\'] : this.currentStyle[\'backgroundImage\'].split(\'\"\')[1]) + ")",
this.runtimeStyle.backgroundImage = "none",
this.src = "{plugindir}/pixel.gif",
this.width = this.style.width | this.clientWidth,
this.height = this.style.height | this.clientHeight
);
}';

And the jQuery code which applies this css to all of the png images :


$(document).ready(function(){
if(($.browser.msie)&(parseInt($.browser.version)<7)){
$("img[src$='.png']").each(function(){$(this).addClass("png");});
}
});

That’s all. The jQuery library is included in the plugin so you don’t need to modify anything.

Installation is simple. Just follow these steps :

  1. Upload ‘wp-pngfix’ directory to the ‘/wp-content/plugins/’ directory
  2. Activate the plugin through the ‘Plugins’ menu in WordPress
  3. Thats all. Go to any page which contains some png images with IE and check if there’s any errors.

This should fix them all except backgrounds now.

Download: Official WordPress plugin page : http://wordpress.org/extend/plugins/wp-pngfix/

Note: This type of fixes cause slight color changes to your png images with background color, so you may have to change some css.If you use images without inner backgrounds and only need to show the background transparent, forget that note :)



Yazıyı Paylaş:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Live
  • Slashdot
  • StumbleUpon
  • Technorati
  • Furl
  • NewsVine
  • Pownce
  • Reddit
  • SphereIt
  • Spurl
  • TwitThis

48 Responses to “pngfix Wordpress Plugin”

  1. Gary Crossey says:

    GOT MY SITE TO VALIDATE WITHOUT ANY VALIDATION WARNING – with PNGFIX

    In the pngfix.php

    Revise the & and < (less-than) sign with the code below.

    if(($.browser.msie)"&"(parseInt($.browser.version)<7)){

    Hope that helps.

    ReplyReply
  2. Gary Crossey says:

    I use the PNGFIX to fix PNG transparency images that I have posted on my gallery page: http://irishguy.info/graphic-design/ – the plug-in works great.

    However, when trying to validate my website I got two warnings.

    if(($.browser.msie)&(parseInt($.browser.version)<7)){

    The first error is for the "&" and the second is for using the "<"

    To solve the first error I changed the & to "&"

    Still trying to figure out how to validate without a warning for the "<" (less than sign) being included.

    Any suggestions. Thanks for the plug-n

    ReplyReply
  3. Is it compatible with wordpress 2.7.1 ? Please help…

    ReplyReply
  4. Brendan says:

    heres the link

    ReplyReply
  5. Brendan says:

    I installed your code for a png hack and at the top of the page on IE 6 I there is excessivel code ” ‘; ?>” (without the quotes)

    On the most recent safari I see ‘; ?>

    I have been trying to get these hacks out for a while and have had no luck. Any help would be appreciated

    ReplyReply
  6. N says:

    Another solution that I found to work, is to add “jQuery.noConflict();” at the beginning of the pngfix.php’s javascript code (right before “jQuery(function($){“).

    ReplyReply
  7. Voya says:

    Hey kardasi! This might be useful, i will test it out later! :D

    Just a note – use javascript without noscript to handle this : If you wish to donate, you can click one of the google ads – it’s against google policy, if they find out that, they will ban you.

    try this instead ( since google can’t read JS, or use an image! )

    document.write ( “If you wish to donate, you can click one of the google ads “);

    cheers :)

    ReplyReply
  8. MuSnake says:

    getting closer…

    change source attribute of line 31 of pngfix.php to:

    [code] '. ABSPATH . WPINC . '/js/jquery.js[/code]

    ReplyReply
  9. MuSnake says:

    Let’s try that again…

    change line 31 of pngfix.php to:

    [code]';[/code]

    ReplyReply
  10. MuSnake says:

    Plugin conflicts with my other jQuery.

    edit pngfix.php, line 31:

    `’;`

    to

    `’;`

    ReplyReply

Leave a reply

tahapaksustartshere tahapaksuendshere