Add PNG Support to WordPress Plugin “Image Shadow”

The Image Shadow plugin for WordPress works pretty well. Unfortunately, it only adds shadows to JPEG images. PNG images can be added very easily, but they will be converted to JPEG format in the image cache. This isn’t optimal for things like screenshots, but the images still look good enough for my needs.

Edit wp-content/plugins/image-shadow/image-shadow.php. Find this line:

if (!preg_match('/\.(jpeg|jpg|jpe)$/i', $src)) return $src;

Add |png to the match expression:

if (!preg_match('/\.(jpeg|jpg|jpe|png)$/i', $src)) return $src;
Posted in Technology, Wordpress | Leave a comment

WordPress Twentyten Theme Without Header Image

The latest version of the Twentyten theme seems to have introduced a bug in the header. If you opt for no header image, you’ll end up with a large space and a broken image icon in your header:

The problem is a conditional in wp-content/themes/twentyten/header.php which writes out an img tag even if get_header_image() returns an empty string:

   // Check if this is a post or page, if it has a thumbnail, and if it's a big one
   if ( is_singular() &&
      has_post_thumbnail( $post->ID ) &&
         ( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'post-thumbnail' ) ) &&
         $image[1] >= HEADER_IMAGE_WIDTH ) :
      // Houston, we have a new header image!
      echo get_the_post_thumbnail( $post->ID, 'post-thumbnail' );
   else : ?>
      <img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" />
   <?php endif; ?>

Replace the else with an elseif which checks to see if the header image string is empty:

   elseif ( get_header_image() != "") : ?>
Posted in Technology, Wordpress | 1 Comment