230 thoughts on “How to Make TimThumb Work With WordPress Multisite Leave a comment

  1. Pingback: Timthumb.php image gallery not working on Multisite Wordpress | SeekPHP.com
  2. Was looking for over a year for a way to grab the first image of a post in WordPress MS, no one here could help… Here is what you need to do.

    It checks for images a few different ways all in one code.

    1. Thanks for the link – unfortunately it doesn’t load so I have removed it. Happy to add it back if you can tell me the correct url

  3. Hi,

    I am trying to to get a photoblog page theme, Framed (by Jinsoma) to work properly on my blogging network. The network was originally created on WPMU. The theme uses timthumb. Even after reading through the post and all of these comments I am still lost.
    Has anyone gotten this to work on a Jinsoma made theme? I also have the Arras theme installed on many of the blog sites and it works with no adjustments.
    Any help as to what line of code to put into which file would be so greatly appreciated. I am on about my 10th page theme for the photoblog and am becoming rather frustrated. The whole time the person whose site it will be is sitting and waiting for it to be ready.

    (The photoblog site is at http://www.abphotography.worldblogosphere.com )

  4. Hi there Ben! I need your awesome help. I just installed my wordpress theme called reviewit yesterday and I’m not so lucky with TimThumb. I put the cache folder located in /public_html/wp-content/themes/reviewit/lib/scripts to 777 and still doesn’t work.

    The code that you recommended to put in the function.php I have it already

    /*************************** TimThumb Image Directory ***************************/

    function get_image_path ($post_id = null) {
    if ($post_id == null) {
    global $post;
    $post_id = $post->ID;
    $theImageSrc = get_post_meta($post_id, ‘ghostpool_thumbnail’, true);
    global $blog_id;
    if (isset($blog_id) && $blog_id > 0) {
    $imageParts = explode(‘/files/’, $theImageSrc[0]);
    if (isset($imageParts[1])) {
    $theImageSrc = ‘/blogs.dir/’ . $blog_id . ‘/files/’ . $imageParts[1];
    return $theImageSrc;

    Also I found this in the function.php

    /*************************** Featured Image Sizes ***************************/

    add_image_size(‘thumbnail’, 120, 120, true);
    add_image_size(‘ghostpool_thumbnail’, 100, 130, true);
    add_image_size(‘slider-image’, 630, 344, true);
    add_image_size(‘slider-thumbnail’, 80, 65, true);
    add_image_size(‘blog-image’, 638, 238, true);
    add_image_size(‘review-box-image’, 212, 120, true);
    add_image_size(‘review-page-image’, 150, 180, true);*/

    My website url is http://www.turmentila.info/ Please give me a hand. Many thanks!

    1. It doesn’t look like your theme is using timthumb.php – you should talk to the person you got the theme from for help with getting more/ different image sizes.

      1. Wrong. You replied me after 1 year so that’s why you find out that there’s no timthumb in the source. I switched to another theme.

  5. I hav a site http://www.christcollegejagdalpur.net, and you can see the thumbnails are not working when I click a category from the category menu.. help me finding a solution or pls help me to remove the unwanted links and boarder that appear before the post title…

    thanks in advance.. pls replay.. I am a student of this college and I am developing this site for my college for free.. pls do help…

  6. Hi
    Please ignore my last post that didn’t work.

    I am using the plugin ‘Download Manager’ (http://www.wpdownloadmanager.com/) and it uses timthumb.php in a number of places to display images and doesn’t support WPMS.

    In one of the page templates for example is calls:-

    $file[‘thumb’] = “”;
    $file[‘thumb’] = “”;

    and in the plugins own functions.php file an example would be:-

    $data[‘thumb’] = “”;

    I’ve added the function in functions.php but how would I amend the code?

    Would really appreciate your input.


  7. Hi,

    I’m having trouble with this timthumb wpmu problem for a long time.
    The thumbs don’t generate. You can see the problem here: http://chabelle.be/cbs/nieuws-cbs/#nieuws-cbs

    I’m not an expert to know if it’s timthumb or something with the theme…

    Can somebody help me with this? It’s for a client of me and been searching very long for a fix.


  8. Okay, so I’ve added this code to functions.php…

    function get_image_path ($post_id = null) {
    if ($post_id == null) {
    global $post;
    $post_id = $post->ID;
    $theImageSrc = get_post_meta($post_id, ‘Image’, true);
    global $blog_id;
    if (isset($blog_id) && $blog_id > 0) {
    $imageParts = explode(‘/files/’, $theImageSrc);
    if (isset($imageParts[1])) {
    $theImageSrc = ‘/wp-content/blogs.dir/’ . $blog_id . ‘/files/’ . $imageParts[1];
    return $theImageSrc;

    but that doesn’t seem to work. when I look at the slider, and look at the image info for the image that isn’t working, I see that the img source is:


    Any thoughts?

  9. I was able to fix my issue by doing TWO things.

    I turned this line to true: [line 33]

    if(! defined(‘ALLOW_ALL_EXTERNAL_SITES’) ) define (‘ALLOW_ALL_EXTERNAL_SITES’, TRUE); // Less secure.

    and I commented out this line [line 212]
    //$this->src = preg_replace(‘/https?:\/\/(?:www\.)?’ . $this->myHost . ‘/i’, ”, $this->src);

    Whether or not this is an appropriate way, it is the fix I found to work after 8+ hours of troubleshooting.

    Hopefully this helps some people!

    1. Thank you Jacob Raccuia, I searched per hours on the internet and tested, nothing worked. Finally I tried your solution and it works perfectly ! thanks a lot πŸ™‚

    2. Hours ?? I spent 3 days to find this ! And when I almost gave up and turn back to add_image_size() … So – BIG THANKS (at this moment I don’t give much damn if it’s less secure or what …)

    3. Excellent suggestion, Jacob. Thank you! I think it would be better to add this to a timthumb-config.php file, rather than changing line 33:

      $ALLOWED_SITES = array (

      This would still allow the same functionality that you suggested, but it would limit the danger by only allowing images from the intended domain.

      I do agree that it’s necessary to comment out the preg_replace line to get this to work smoothly, though. Nice catch! I wonder why this isn’t done by default?

      1. Hrm. Well that didn’t work. In between the empty single quotes of the array should go your domain name. Sorry for the confusion.

    4. I implemented your advice on a couple of my sites and was hacked via timthumb shortly thereafter. By setting ALLOW_ALL_EXTERNAL to true, you let a hacker upload php scripts from their website to your timthumb cache directory where they are able to execute the script.

      Here’s how to do this properly:

      1. Make sure that ALLOW_EXTERNAL is set to TRUE [line 32] and ALLOW_ALL_EXTERNAL is set to FALSE [line 33]

      2. Comment out [line 212]
      //$this->src = preg_replace(‘/https?:\/\/(?:www\.)?’ . $this->myHost . ‘/i’, ”, $this->src);

      3. Go to the $ALLOWED_SITES array [line 125] delete all the default sites, and add your site’s domain.

      I would also recommend downloading the Timthumb scanner plugin and installing on your root site to make sure you’ve fixed all the versions of timthumb in your wp-content folder.

      1. Hi Peter – really sorry to hear you were hacked. This problem was found 1 and a half years ago and was fixed in version 2 of TimThumb. I would recommend keeping the software up to date so that you can solve these issues before they happen.

      2. Hi Peter – I’m new at this and I do not understand is the file I should modify timthumb.php – functions.php or some other file? . From already thank yo

    5. IT WORKS!!!! Thank you, thank you thank you. 2 months ago I spent even more days trying to fix it before giving up. Then trying again now I have spent hours trying to fix this problem.

      Don’t know how you came up with the solution, but good job! You got some skills there.

    6. OH MY GOSH! THANKS for this suggestion!!!! I’m back to life again πŸ˜€ Be sure to check out BENs reply below too!

  10. I get this message, Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 20736 bytes) in /storage/content/49/146049/unitedsardinefactory.com/public_html/wp-content/themes/blacklabel/framework/timthumb.php on line 1085

    Any idea what the problem is? I run WordPress as an installation on my webhost, so I don’t think I have access to the files. Help would be so appreciated.

    1. The problem is in the description. Your server ran out of memory. You were probably trying to resize an image that is too big

  11. I created a script that loads timthumb.php into wordpress, it uses multisite. it is basically a function that you can call from your wordpress template /widget/plugin

    It can be found here https://github.com/moyarich/wordpress_timthumb_multisite

    this script supports all acceptable timthumb parameters http://www.binarymoon.co.uk/2012/02/complete-timthumb-parameters-guide/

    How to use:
    1. you add the mr_timthumb function to your functions.php
    2. edit the location to the timthumb.php script , change the value for the variable $timthumblocation
    3. then call timthumb like so

    $timthumb_img_param = array(
    ‘src’ => $orig_uploaded_img,
    ‘h’ => 315,


    1. Thanks for the contribution. Personally I don’t see a need for this – TimThumb isn’t difficult to use. But perhaps others will like it.

    1. If you view the image you will see the error. In this case the GD library does not exist which means TimThumb can’t work

  12. i don’t this workaround is working anymore with new installs of WPMU using WP3.5.1 – works for subdomain setup but am having issues with the subfolder setup

    anyone else notice this?

    1. sorry that should have read…

      i don’t “think” this workaround is working anymore with new installs of WPMU using WP3.5.1 – works for subdomain setup but am having issues with the subfolder setup

      anyone else notice this?

  13. No. I don’t think this works now either. I’ve been trying for two days to get this to work too and it’s getting on my nerves. I’m using a theme which had timthumb embedded (Splashing Pixels ‘Mio’ so I’m kind of stuck with it)
    So many ‘fixes’ which just seem to cause other problems.
    Everything works on the main site but can’t get any images on the subfolder sites.
    Any help gratefully received

  14. Just keep getting

    Could not find the internal image you specified.

    errors even though the image is there when you grab just the image url.

  15. The new wordpress multisite is not longer using blog.dir directory so this code doesn’t work anymore with wordress uploaded images. And i can’t figure out how to fix it, any thought?

  16. Did anyone ever find a resolution to this? I’m using Userpro plugin, which uses Timthumb and I’m coming up against the same problem.

Leave a Reply

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