The MU forums have moved to WordPress.org

Tim Thumb not displaying thumbnails on masterblog through secondary blogs (41 posts)

  1. mark_trashed
    Member
    Posted 14 years ago #

    Hi,

    So I have successfully installed WP MU on the following domain:

    http://www.trashedmag.com/members/

    That is the "Master Blog" so to speak

    Secondary blogs are set up as follows"

    http://www.trashedmag.com/members/schoolname/

    We have successfully made the Tim Thumb script work so that it generates the thumbnails where neccessary.

    I have the categories of "Recent" "Featured" and "News" across both the Master blog and the secondary blogs.

    I want the Master blog to be able to display posts from the secondary blogs, which it currently does by matching the Category and displaying in the neccessary spot on the page

    The problem seems to lie with the thumbnail being created here. It works fine for creating a thumbnail for a post that was created in the master blog or a post that was created in the secondary blog and displaying those on the page, but not when it comes to displaying a post created in the secondary blog and showing on the master blog too

    Hope that makes sense and if anyone could lend a hand, it would be greatly appreciated

    thanks
    mark

  2. kgraeme
    Member
    Posted 14 years ago #

    I'm going to make two assumptions:

    1. The way the theme uses the tim thumb images is as a custom field on a post.
    2. You're using Donncha's sitewide tags plugin to try and copy the posts from the secondary blogs to the main blog.

    If these fit your case, then the problem is that Donncha's sitewide tags doesn't pass custom field information. No custom field information, no thumbnail reference being passed from sub-blog to main blog.

  3. andrea_r
    Moderator
    Posted 14 years ago #

    See here:
    http://www.binarymoon.co.uk/2009/10/timthumb-wordpress-mu/

    kgraeme - nope, it doesn't use custom fields.

  4. mark_trashed
    Member
    Posted 14 years ago #

    Hi both,

    I am not using the Sitewide Tags plugin, merely using the category name to match and then display on the homepage, which seems to work?

    I think Tim Thumb then needs a hack to rebuild the URL so that it's the full URL of the image at the point where it copies from the secondary blog to the master homepage? Any idea on how to do this please?

    thanks

  5. andrea_r
    Moderator
    Posted 14 years ago #

    Did you read the link I posted above?

  6. mark_trashed
    Member
    Posted 14 years ago #

    Hi Andrea,

    Ok, sorry I got confused. I AM using the Sitewide Tags plugin. So it will display posts from other blogs on the Main blog homepage just fine.

    I have read the post on Binary Moon, and we have it working on separate blogs just fine. Just I don't seem to understand how to display the same thumbnails from a secondary blog on the master homepage.

    If you see Jame's post on Binary Moon (he's working with me), then we have it working correctly, just not on the master page for pulling in the other posts...

    Any idea please?

    thanks

  7. kgraeme
    Member
    Posted 14 years ago #

    Yep, now I'm even more sure it's because of the sitewide tags plugin not passing the custom fields.

  8. mark_trashed
    Member
    Posted 14 years ago #

    Yeah, that is definitely what seems to be the problem. Is there any way that the plugin can be changed so that it does. Anyone know of a workaround please?

    thanks

  9. andrea_r
    Moderator
    Posted 14 years ago #

    Darn it, there's a thread in here somewhere with the specific on how to edit SWT to get the custom field details and I cannot for the life of me find it.

    (when/if I do, I will stick it in my "mu forums links" file...)

  10. DeannaS
    Member
    Posted 14 years ago #

    I actually emailed Donncha with an update to his plugin that lets site admins decide if custom fields should be carried forward or not. But, I've never heard back from him.

    So....thoughts - stick the whole thing in pastebin or upload it in a plugin repository as a modified version? Or send it "off line" to people that request it? Or, just pull out the bits and pieces and stick 'em here for people that want to do the mods themselves? What say you?

  11. andrea_r
    Moderator
    Posted 14 years ago #

    Likely D was pretty busy at the time & forgot.

    I'd stick 'em in here for people to mod themselves for now. I have a couple more ideas & stray code for SWT mods, and I think it'd be better community-wise to have one version with the goodies rolled in (or 2 if needed), rather than 3 or more to confuse the noobs.

    Sounds about fair?

  12. DeannaS
    Member
    Posted 14 years ago #

    Yah, that's kinda what I figure, too.

    So...mods - all line numbers are fairly inaccurate, because I've got other stuff shifted around, so I'll give you an approximate line number and a line of existing code.

    after this line (round about line 170 or so

    $permalink = get_permalink( $post_id );

    Add this

    //let's get all the custom meta fields
    $statement = "SELECT * FROM $wpdb->postmeta WHERE post_id = " . $post_id . " AND  meta_key NOT IN ('_edit_last', '_edit_lock')";
    $customfields = $wpdb->get_results($statement);

    Then, round about line 200 or so after this line

    $p = wp_insert_post( $post );

    Add this chunk:

    // copy over the custom fields, if desired
    
    if ($include_custom == true) {
    	foreach ($customfields AS $row) {
    	//  add each post meta
    	add_post_meta($p, $row->meta_key, $row->meta_value, true);
    	// it's probably more effecient to just run edit, too, instead of checking for changed data....(but never update a permalink one - we need that to be the one set in the tags blog
    	if ($row->meta_key != 'permalink') {
    	update_post_meta($p, $row->meta_key, $row->meta_value);
    		}
    
    	}
    }

    This will copy over all your custom fields (except the internal ones). The other snippet in the forums just copies over certain ones. So, if you want to copy over just certain ones, search for that other thread.

  13. DeannaS
    Member
    Posted 14 years ago #

    Oh, and the stuff I haven't dealt with is deleting this stuff later on. There isn't a great way to do that.

  14. mark_trashed
    Member
    Posted 14 years ago #

    DeannaS, thanks! I will give this a go tonight and see what the outcome is. In your last post where you talk about deleting the stuff later on. Is that going to cause me problems if I inset the code you have pasted above?

    thanks in advance
    Mark

  15. DeannaS
    Member
    Posted 14 years ago #

    It shouldn't cause any MAJOR problems. But, be aware that if a user on a sub blog deletes a tim thumb image, it won't be deleted from the sitewide tags blog. That's because there's no good way to connect the two. I debated deleting all custom field when a user edits a post and re-inserting them. But, the downfall of that is that if you're using the sitewide tags blogs to do any special stuff that requires the custom fields, you'll break that functionality. So it's sort of a matter of knowing how YOUR system works and what the best solution would be.

  16. kgraeme
    Member
    Posted 14 years ago #

    Andrea, you may be interested that Deanna dug into that when we were looking into ways to optimize the blog topics plugin. We're not keen on changing the blog topics queries though if it relies on an unsupported modification of Donncha's sitewide tags.

    The biggest issue with the modification, as Deanna was saying, is that there's no relationship between the sub blog and tags blog custom fields. It's just a simple one-way copy.

  17. andrea_r
    Moderator
    Posted 14 years ago #

    Hmmm, I just realized a conversation like this is what Google Wave is meant for. :D

  18. mark_trashed
    Member
    Posted 14 years ago #

    Thanks Deanna, just got in so will give it a go and let you know how I get on

  19. mark_trashed
    Member
    Posted 14 years ago #

    Ok, i've added and updated the sitewide-tags.php, but it doesn't seem to have made any difference unfortunately?

    Do I need to clear the cache or something?

    http://www.trashedmag.com/members/

    thanks

  20. joseffb
    Member
    Posted 14 years ago #

    I know I made a template that pulled custom fields coming from main blog to child and vice versa. I had to change the active blog to the ID that I wanted to pull the custom field from, pull the custom fields then change it back to the current blog id. I have to look for the code, but I got it from this board originally. Hope that helps.

  21. kgraeme
    Member
    Posted 14 years ago #

    mark_trashed, go to the sub blog and update the posts. The sitewide tags code that copies posts to the home blog only happens when a post is explicitly published/updated.

  22. mark_trashed
    Member
    Posted 14 years ago #

    Ok, I just made a post here:

    http://trashedmag.com/members/marktest/2009/10/20/wordle-test-post/

    This works fine on the sub blog

    It shows up fine on the homepage

    http://trashedmag.com/members/

    But the code from Deanna which I added to the sitewide-tags.php doesn't seem to have had any effect?

  23. DeannaS
    Member
    Posted 14 years ago #

    I've not used timthumb before. Are we sure it even uses custom fields?

  24. mark_trashed
    Member
    Posted 14 years ago #

    timthumb definitely uses custom fields too

  25. DeannaS
    Member
    Posted 14 years ago #

    Okay, try this. Go to a sub blog. Create a post. Give it a custom field. Submit it.

    Go to the sitewide tags blog. Edit the post. Are the custom fields you manually created there?

  26. mark_trashed
    Member
    Posted 14 years ago #

    Ok, thanks

    But what I am trying to work out is the post that shows first in both the top feature box and the 1st row of boxes after that on this page:

    http://trashedmag.com/members/

    It's the one entitled "Wordle test post"

    I've ticked the box on the Options as follows:

    Post to main blog
    Create posts in your main blog. All posts will appear on the front page of your site. Remember to to add a post loop to home.php in the theme directory if it exists.

    So it does show up on the main homepage

  27. DeannaS
    Member
    Posted 14 years ago #

    Right, and the post is there, right? Just not the image? So, we're trying to help you figure out why the image isn't there. Did you do what I suggested?

  28. mark_trashed
    Member
    Posted 14 years ago #

    Yes, that's correct. Post is there, just not the image, which is what I'm trying to fix

    I added the code you posted above as so:

    $permalink = get_permalink( $post_id );
    	//let's get all the custom meta fields
    	$statement = "SELECT * FROM $wpdb->postmeta WHERE post_id = " . $post_id . " AND  meta_key NOT IN ('_edit_last', '_edit_lock')";
    	$customfields = $wpdb->get_results($statement);

    and

    $p = wp_insert_post( $post );
    		// copy over the custom fields, if desired
    
    		if ($include_custom == true) {
    		foreach ($customfields AS $row) {
    		//  add each post meta
    		add_post_meta($p, $row->meta_key, $row->meta_value, true);
    		// it's probably more effecient to just run edit, too, instead of checking for changed data....(but never update a permalink one - we need that to be the one set in the tags blog
    		if ($row->meta_key != 'permalink') {
    		update_post_meta($p, $row->meta_key, $row->meta_value);
    		}
    
    	}
    }

    I put this in the sitewide-tags.php. But it doesn't seem to have made a difference unfortunately...

  29. mark_trashed
    Member
    Posted 14 years ago #

    The custom field in this instance is named 'thumb' just so that you know.

  30. DeannaS
    Member
    Posted 14 years ago #

    Could you please do as I asked and check to see if a manually added custom field transfers? (There's a reason I'm asking you to do it. Seriously.)

About this Topic

  • Started 14 years ago by mark_trashed
  • Latest reply from mark_trashed