The MU forums have moved to WordPress.org

htaccess throwing off image resizer? (14 posts)

  1. savesheep
    Member
    Posted 15 years ago #

    Hello,

    I’m dying to get this timthumb image resizer to work, I’m using WPMU and it isn’t liking it for some reason. I’ve followed everything step by step, but it never generates an image. I’m assuming it has something to do with the way WPMU configured my .htaccess file. Anyway, http://sheaallen.com/wp-content/themes/arthemia/scripts/timthumb.php?src=files/2008/08/143014w_sm.gif&w=300&h=275&zc=1&q=100

    My .htaccess file contains the following three lines which I think may be throwing it off:

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

    If I move both the timthumb.php file AND the sample.gif out of the main wordpress folder, then it works no problem. Any suggestions?
    http://www.sheaallen.com/timthumb.php?src=sample.gif&h=300&w=275&zc=1

  2. konus
    Member
    Posted 15 years ago #

    You can add this to the firsts lines (about 16):

    require("../../../wp-blog-header.php");

    if( !defined( "BLOGUPLOADDIR" ) )
    define( "BLOGUPLOADDIR", WP_CONTENT_DIR . "/blogs.dir/{$wpdb->blogid}/" );

    And then...
    use

    $src = BLOGUPLOADDIR . str_replace( '..', '', $src );

    instead of the classic "$src" of the script...

  3. savesheep
    Member
    Posted 15 years ago #

    Hey Konus, thank you for the reply!

    I added those four lines to the top and I believe the right area to place the $src script would be near line 29 (right below the //get path to image on file system.

    Removed:
    $src = $doc_root . '/' . $src;

    I only assume this because all I should use now in the src is the name of the file, right? Instead of using its full path, it retrieves this on its own and just looks for the file name?

    Thanks!

  4. konus
    Member
    Posted 15 years ago #

    OK, in my file is in the line 35 (just before $new_width = preg_replace...)

    For me this hack works if you call the image (src) with the full path

    instead of:

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

    You _must_ use:

    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

    By the way... I asume that you're using wpmu.

    [Edited]
    yeah.. the Timthumb search for the absolute path of the file, so that's the base of this trick.

  5. savesheep
    Member
    Posted 15 years ago #

    Hey Konus,

    yes I am using wpmu. I believe I have your hack set up perfectly, but it still isn't working. Could you send me your timthumb.php page by any chance or just post the entire source code so I can make sure we have the same system?
    What gets me is that the timthumb.php works fine as long as the script, the cache folder AND the image is outside of the wp-content folder. I can only assume your .htaccess is pretty much the same as mine so if its working for you it can't be causing my problem right?

  6. savesheep
    Member
    Posted 15 years ago #

    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 this link still doesn't work. it doesn't produce an error message, but it doesn't show an image either. the cache folder IS set to 0777 but there has never been an image created in it. thus the cache folder is located http://sheaallen.com/wp-content/themes/arthemia/scripts/cache/

  7. konus
    Member
    Posted 15 years ago #

    ok, I realize that there are another changes (sorry, I forgot)

    you can try this one: http://cl1p.net/konus/

    the htaccess is the standard, remember check twice your folder permission...

    You can debug accessing directly to the timthumb.php, in my case, without parameter print : no image specified... I think that you need to see that result in order to have the script working...

    Tell me if work.

  8. savesheep
    Member
    Posted 15 years ago #

    I copied and pasted your code into my timthumb.php file, reuploaded it and checked permissions on both the cache folder (0777) and timthumb.php (0755). The scripts folder, should it just be standard 0755?

    and you are right, the script doesn't display anything when you just goto http://www.sheaallen.com/wp-content/themes/arthemia/scripts/timthumb.php

    BUT my unmodified one, http://www.sheaallen.com/timthumb.php works NO PROBLEM. so i don't get why its not working living in that wp-content folder.

  9. savesheep
    Member
    Posted 15 years ago #

    Okay, I got the code to error on me now.

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

    this is the error i typically get. Why is it looking for the image in that path? Why isn't the modrewrite working correctly to change its path?

    btw, i didn't use your copy here, i redownloaded the original timthumb from the site to get it to work again.

  10. savesheep
    Member
    Posted 15 years ago #

  11. savesheep
    Member
    Posted 15 years ago #

    okay, so i edited the php of my index template and changed it so the img src = http://www.sheaallen.com/timthumb.php?src=http://www.sheaallen.com/wp-content/blogs.dir/1/<?php
    $values = get_post_custom_values("Image"); echo $values[0]; ?>&w=300&h=275&zc=1&q=100

    its all working now. this was really stupid, there has to be a way for it to be fixed. haha. it actually does a modrewrite to the blogs.php?file= which does another rewrite to the actual file name.

  12. konus
    Member
    Posted 15 years ago #

    Hahha... I never try your actual template... ^^ So... I guess... when you write a new post with a special value "Image"... you need to put the full url to the image. This could be found easily when you add new Media in your panel. It's a simply rule, but works.

    the blogs.php?file= protect the access to other files than "jpg,png...etc" included in the media array, so could be nice, use the wordpress default "sizes" of the pictures in your template instead of timthumb, but... it's no so nice :)

    Impoves to "blogs.php" couldn't be a possibility, because depends on the wp code...

  13. chrismac09
    Member
    Posted 15 years ago #

    I believe I have followed everyone here's advice to a tee, but still cannot get the resizer to work correctly. I have found that the timthumb script works properly with images stored in a sub-directory off of my root directory that I made myself and uploaded to with an FTP client. It cannot, however, produce the thumbnails for images hosted through the Wordpress upload tool (which means they are inside of the wp-content/blogs.dir/1/files/ directory. I instead am presented with a lovely "//files/2009/03/apkinar-and-benmark.jpg not found." message, which seems to indicate that the script is working properly, but the htaccess file and mod-rewrite gizmos are having issues with timthumb.

    I am only just getting started with this, so I understand little about htaccess and the php code itself. I have tried muddling through and making some of the simpler fixes in notepad to no avail.

  14. andrea_r
    Moderator
    Posted 15 years ago #

    Use Justin Tadlock's "get the image" plugin instead of timthumb.

About this Topic

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