WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] [closed] Timthumb, Multisite, and Featured Images...Help? (8 posts)

  1. justbishop
    Member
    Posted 3 years ago #

    First of all, I know (re: my WP version). I do all updates for my network on Fridays, so that my child site admins know when to look for possible wakiness from newly incompatible plugins.

    So...I'm trying to get a theme (Pure3) that uses timthumb.php to work on my child sites, but it's not generating the thumbnails into the cache folder like it's supposed to (folder is empty). I've set the cache folder and timthumb.php files to several different permissions to no avail. I've contacted my host, and PHP-GD is active, so I know that's not the issue. Now i'm reading that the URL for images in a multisite child site is virtual, which causes the issue.

    There seem to be lots of tuts online for solving this problem when the theme has timthumb.php looking for the image in a custom field, but the theme I'm using has it looking for the "featured image" for each post. I'm not coming up with any solution for this particular situation (multisite + featured post). Anyone have ideas?

  2. *handwave* 3.2 is new ;) We won't give you grief until 3.2.2 is out.

    Anyway. TimThumb is notoriously dumb on MultiSite.

    http://odotteeaux.com/blog/2011/02/14/timthumb-php-fix-for-wordpress-mu/ may help.

  3. justbishop
    Member
    Posted 3 years ago #

    Thanks :)

    I did come across that tutorial in my googling today, but it details how to modify the URL if using a custom field to set the image. I can't seem to wrap my mind around how to further mod the mod to use whatever is set as the "featured image" instead.

    Here's the piece of code I'm working with:

    http://pastebin.com/TbinSktD

  4. I'd imagine it would have to do with http://codex.wordpress.org/Function_Reference/the_post_thumbnail but ... I've never used timthumb :/

  5. justbishop
    Member
    Posted 3 years ago #

    Thanks, I've been trying some different things and code snippets found via a search here, but still can't get timthumb.php to generate images into the cache folder. How would that work with multisite, anyway? The cache folder for timthumb is in the theme folder, but all sites using the theme would basically be sharing it from the same folder?

    I'm getting really frustrated and sad that I spent cash on a theme for the first time ever only to have it not work the way it's supposed to :(

  6. Cara Peckens
    Member
    Posted 3 years ago #

    This is what I have done to get timthumb to work with multisite. You need to add this code to your theme's functions.php file

    <?php function get_image_path($src) {
    global $blog_id;
    if(isset($blog_id) && $blog_id > 0) {
    $imageParts = explode('/files/' , $src);
    if(isset($imageParts[1])) {
    $src = '/blogs.dir/' . $blog_id . '/files/' . $imageParts[1];
    }
    }
    return $src;
    }
    ?>

    And then where the timthumb script is used in the theme, you need to modify to this:

    <img src="<?php bloginfo('template_url'); ?>/includes/timthumb.php?q=100&w=180&h=200&zc=1&a=t&src=<?php echo get_image_path(get_post_meta($post->ID, 'postImage', true)); ?>" alt="" />

    where postImage is the name of the meta field the holds the image URL.

  7. justbishop
    Member
    Posted 3 years ago #

    Thanks for the info @cpeckens! I went ahead and changed the current theme I'm working on to just use custom thumbnail sizes instead of timthumb, but the others that I'm going to be modding for multisite use (from the same theme author) also use timthumb, so I might give this solution a shot on those :)

    One question, though...what would I replace "postImage" with if I wanted it to use whatever was set to the featured image (rather than a custom field)?

  8. Jeff
    Member
    Posted 2 years ago #

    @cpeckens - Thanks!

    Was having an issue with a plugin I'd built not displaying thumbnails in multiuser and your code snippet was the cure.

    Now I need to figure out why Fancybox is not popping the original image in a thickbox and, instead, naving to the actual image. Trudging along.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.