June 28, 2010

WordPress plugin: WP Smush-it

by Karine in Wordpress with 2 responses

You probably already know about Yahoo Smush.it tool ! It reduces images file size but keeps the images quality (for real, it really does a good job). WP Smush-it is a WordPress plugin that automatically smush your images. It's incredibly helpful if you are too lazy to optimize all your images for the web like me. :) You can also use it to smush your existing images (but you will have to do it one by one).

The only problem I had with this plugin is that it didn't work for me because my upload folder wasn't in the wp-content directory. I had to tweak it a bit to make it work (I didn't want to wait for the next upgrade). Here is what I did:

Look for line 127

// check that the file is within the WP_CONTENT_DIR

Add this right after it :

$upload_dir = wp_upload_dir();
$wp_upload_dir = $upload_dir['basedir'];
$wp_upload_url = $upload_dir['baseurl'];

Replace WP_CONTENT_DIR by $wp_upload_dir

And WP_CONTENT_URL by $wp_upload_url

in lines 128, 129, and 135.

Voilà, thank you for this wonderful plugin for all Page Speed/YSlow freaks like me ! :D

Tags

2 thoughts

  1. marion
    on March 4, 2011
    at 05:21 AM

    Does this work even if images are not in media library? My images in are in a subdomain but not in media library

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Notify me of followup comments via e-mail. You can also subscribe without commenting.

↑ Back to Top