The MU forums have moved to WordPress.org

TimThumb.php Not Working (10 posts)

  1. savesheep
    Member
    Posted 15 years ago #

    I got this script to resize images from: http://www.darrenhoyt.com/2008/04/02/timthumb-php-script-released/

    It's really basic and I've seen it work on other servers before. It's just not working on mine.

    I created the cache folder and gave it 777 permissions, though its still not putting the image in the cache. I'm assuming its a .htaccess problem it may be having finding the original image?

    http://sheaallen.com/wp-content/themes/arthemia/scripts/timthumb.php?src=http://sheaallen.com/files/2008/08/143014w_sm.gif&w=300&h=275&zc=1&q=100 see? nothing loads!

    this is my .htaccess file contents:

    RewriteEngine On
    RewriteBase /

    #uploaded files
    RewriteRule ^(.*/)?files/$ index.php [L]
    RewriteCond %{REQUEST_URI} !.*wp-content/plugins.*
    RewriteRule ^(.*/)?files/(.*) wp-content/blogs.php?file=$2 [L]

    # add a trailing slash to /wp-admin
    RewriteCond %{REQUEST_URI} ^.*/wp-admin$
    RewriteRule ^(.+)$ /$1/ [R=301,L]

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule . - [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-.*) $2 [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
    RewriteRule . index.php [L]

    <IfModule mod_security.c>
    <Files async-upload.php>
    SecFilterEngine Off
    SecFilterScanPOST Off
    </Files>
    </IfModule>

    Thanks!

  2. xenon2050
    Member
    Posted 15 years ago #

    Well I had a similar problem and ended up figuring out a work around by specifying the exact directory. It is just a work around though not the ideal way to do it, but then it did just require a little bit of code editing and a slight change in the way I do the thumbnails.

  3. VentureMaker
    Member
    Posted 15 years ago #

  4. Klark0
    Member
    Posted 15 years ago #

    Why not use the built in function for thumbs. For each image you upload, Wordpress creates 3 files of different sizes. You just need to set your options under Settings > Miscellaneous.

  5. xenon2050
    Member
    Posted 15 years ago #

    Opps, probably should have linked that back to the other post. Thanks for linking it. Problem was I made this post because I couldn't figure the script out, then like ten minutes later I figured it out and thought I should edit the post.

    Klarko - Hmm, I guess that is a option. As stupid as this will sound I was trying to figure out where those thumbnails came from... ;) Maybe I'll try that out. It would be nicer than fooling around with this script... Though the script does let you pick any size... I think the theme author used the script because they used 2-3 different thumbnails.

  6. ehegwer
    Member
    Posted 15 years ago #

    Hey xenon2050 - mind sharing the path you ended up using? I'm stuck, too.

  7. xenon2050
    Member
    Posted 15 years ago #

    Hey ehegwer, sorry I didn't see this sooner.
    Is this what you are looking for?
    Changed:
    <?php $image = get_post_meta($post->ID, 'Image URL', true); ?>
    to
    <?php $image = 'http://tony.therustedmusket.com/wp-content/blogs.dir/3/' . get_post_meta($post->ID, 'Image URL', true); ?>

  8. beargulch
    Member
    Posted 14 years ago #

    timthumb.php works well. Here's what my image call looks like:

    <?php echo get_post_image (get_the_id(), '', '', '' .get_bloginfo('template_url') .'/scripts/timthumb.php?zc=1&w=150&h=150&src='); ?>

    timthumb.php must be in your theme's folder in a scripts/ subfolder, with a cache folder beside it.

    the get_post_image function must be in your theme's functions.php file:

    -----------------
    //GET-POST-IMAGE script by Tim McDaniels, written for the Mimbo theme

    function get_post_image ($post_id=0, $width=0, $height=0, $img_script='') {
    global $wpdb;
    if($post_id > 0) {

    // select the post content from the db

    $sql = 'SELECT post_content FROM ' . $wpdb->posts . ' WHERE id = ' . $wpdb->escape($post_id);
    $row = $wpdb->get_row($sql);
    $the_content = $row->post_content;
    if(strlen($the_content)) {

    // use regex to find the src of the image

    preg_match("/<img src\=('|\")(.*)('|\") .*( |)\/>/", $the_content, $matches);
    if(!$matches) {
    preg_match("/<img class\=\".*\" title\=\".*\" src\=('|\")(.*)('|\") .*( |)\/>/U", $the_content, $matches);
    }
    $the_image = '';
    $the_image_src = $matches[2];
    $frags = preg_split("/(\"|')/", $the_image_src);
    if(count($frags)) {
    $the_image_src = $frags[0];
    }

    // if src found, then create a new img tag

    if(strlen($the_image_src)) {
    if(strlen($img_script)) {

    // if the src starts with http/https, then strip out server name

    if(preg_match("/^(http(|s):\/\/)/", $the_image_src)) {
    $the_image_src = preg_replace("/^(http(|s):\/\/)/", '', $the_image_src);
    $frags = split("\/", $the_image_src);
    array_shift($frags);
    $the_image_src = '/' . join("/", $frags);
    }
    $the_image = '<img alt="" src="' . $img_script . $the_image_src . '" />';
    }
    else {
    $the_image = '<img alt="" src="' . $the_image_src . '" width="' . $width . '" height="' . $height . '" />';
    }
    }
    return $the_image;
    }
    }
    }

    ?>

    -----------------

    and then it all just works.

  9. Ovidiu
    Member
    Posted 14 years ago #

    by any chance, has this been reported back to the author of timthumb? maybe it can be incorporated back into the original plugin?

    that way, word would spread faster as there are a lot of themes using it...

  10. andrea_r
    Moderator
    Posted 14 years ago #

    I wish the themes would switch to using the internal thumbnails. :) timthumb was written before WP had thumbs.

    We did track down why it didn't show thumbnails when pulling posts sitewide, and we did submit the fix back to the person working on an updated version (BinaryMoon).

About this Topic

  • Started 15 years ago by savesheep
  • Latest reply from andrea_r