Thumbnails on Network theme 1.03, WPMS 3.1, BP 1.2.8, Multi-DB 3.05

Hi,
I'm setting up "Show blog posts or show network posts?" to "network posts, and network post I can see on my front page, except thumbnails (same is what i choose "Blog posts" option).

Some post have uploaded images and on some are linked images from other sites (images are regulary appear when I look post directly). No errors in my PHP log file.

What can be a problem?

P.S. A suggest new feature for Network theme ver. 1.4. Opposite function than "Exclude these blogs from the featured display", "Include only these blogs from the featured display". So admin can choose on of this options. Also, great thi can be that "Include only these blogs from the featured display" is correlation with Supporter plugin.

Thnx.
Srecko

    Timothy Bowers

    Sorry, are you saying the thumb is not being displayed?

    If so then here is a quick fix:

    Open the following file:

    themes/network/library/functions/timthumb.php

    Locate line 493 there should be a function show_cache_file()

    function show_cache_file ($mime_type) {
    	// use browser cache if available to speed up page load
    	if (isset ($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
    		if (strtotime ($_SERVER['HTTP_IF_MODIFIED_SINCE']) < strtotime('now')) {
    			header ('HTTP/1.1 304 Not Modified');
    			die ();
    		}
    	}
    
    	$cache_file = get_cache_file ($mime_type);
    
    	if (file_exists ($cache_file)) {
    
    		// change the modified headers
    		$gmdate_expires = gmdate ('D, d M Y H:i:s', strtotime ('now +10 days')) . ' GMT';
    		$gmdate_modified = gmdate ('D, d M Y H:i:s') . ' GMT';
    
    		// send content headers then display image
    		header ('Content-Type: ' . $mime_type);
    		header ('Accept-Ranges: bytes');
    		header ('Last-Modified: ' . $gmdate_modified);
    		header ('Content-Length: ' . filesize ($cache_file));
    		header ('Cache-Control: max-age=864000, must-revalidate');
    		header ('Expires: ' . $gmdate_expires);
    
    		if (!@readfile ($cache_file)) {
    			$content = file_get_contents ($cache_file);
    			if ($content != FALSE) {
    				echo $content;
    			} else {
    				display_error ('cache file could not be loaded');
    			}
    		}
    
    		die ();
    
        }
    
    	return FALSE;
    
    }

    Straight after the curly brackets/braces { add:

    date_default_timezone_set('UTC');

    So it should look like this:

    function show_cache_file ($mime_type) {
    date_default_timezone_set('UTC');
    	// use browser cache if available to speed up page load
    	if (isset ($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
    		if (strtotime ($_SERVER['HTTP_IF_MODIFIED_SINCE']) < strtotime('now')) {
    			header ('HTTP/1.1 304 Not Modified');
    			die ();
    		}
    	}
    
    	$cache_file = get_cache_file ($mime_type);
    
    	if (file_exists ($cache_file)) {
    
    		// change the modified headers
    		$gmdate_expires = gmdate ('D, d M Y H:i:s', strtotime ('now +10 days')) . ' GMT';
    		$gmdate_modified = gmdate ('D, d M Y H:i:s') . ' GMT';
    
    		// send content headers then display image
    		header ('Content-Type: ' . $mime_type);
    		header ('Accept-Ranges: bytes');
    		header ('Last-Modified: ' . $gmdate_modified);
    		header ('Content-Length: ' . filesize ($cache_file));
    		header ('Cache-Control: max-age=864000, must-revalidate');
    		header ('Expires: ' . $gmdate_expires);
    
    		if (!@readfile ($cache_file)) {
    			$content = file_get_contents ($cache_file);
    			if ($content != FALSE) {
    				echo $content;
    			} else {
    				display_error ('cache file could not be loaded');
    			}
    		}
    
    		die ();
    
        }
    
    	return FALSE;
    
    }

    Q for devs - Does the theme not use Wordpress default time settings?

    I got these errors before making my quick fix:

    Warning: strtotime() [function.strtotime]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'UTC' for 'GMT/0.0/no DST' instead in /public_html/wp-content/themes/network/library/functions/timthumb.php on line 508

    Warning: Cannot modify header information - headers already sent by (output started at /public_html/wp-content/themes/network/library/functions/timthumb.php:508) in /public_html/wp-content/themes/network/library/functions/timthumb.php on line 512

    Warning: Cannot modify header information - headers already sent by (output started at /public_html/wp-content/themes/network/library/functions/timthumb.php:508) in /public_html/wp-content/themes/network/library/functions/timthumb.php on line 513

    Warning: Cannot modify header information - headers already sent by (output started at /public_html/wp-content/themes/network/library/functions/timthumb.php:508) in /public_html/wp-content/themes/network/library/functions/timthumb.php on line 514

    Warning: Cannot modify header information - headers already sent by (output started at /public_html/wp-content/themes/network/library/functions/timthumb.php:508) in /public_html/wp-content/themes/network/library/functions/timthumb.php on line 515

    Warning: Cannot modify header information - headers already sent by (output started at /public_html/wp-content/themes/network/library/functions/timthumb.php:508) in /public_html/wp-content/themes/network/library/functions/timthumb.php on line 516

    Warning: Cannot modify header information - headers already sent by (output started at /public_html/wp-content/themes/network/library/functions/timthumb.php:508) in /public_html/wp-content/themes/network/library/functions/timthumb.php on line 517

    Hope this helps anyway!

    msrecko

    Hi,
    it is not help for me. I'm using already UTC time zone on my server.

    I notice that I do not have (after post creation) any cached file (picture) in appropriate folder
    - for Network posts option in ...../blogs.dir/BlogID/cache/.... (even cache folder is not created after post creation) - chmod for blog.dir is OK
    - for Blog posts option .../uploads/cache ... (this cache folder I've create manually with chmod 775)

    So, I've try both options (Network and Blog posts), also I've try with manual post insertion (classic way) and with xmlrpc, but with out success.

    I do not have any error in log file.

    So I believe that bug is in filed where plugin have to create cached picture.

    Pls. help.

    Tnx.
    Srecko

    msrecko

    Hi Tim,
    I've play little bit during the day and conclusion are:
    - timthumb.php initially not support unlimited external site's (but I've tweaked it )
    - timthumb.php have error when try to create cache DIR in blogs.dir/BlogId, I've put after
    {Line 26} define ('DIRECTORY_CACHE', '../../../../blogs.dir/'.$blogdirid.'/cache'); // cache directory

    at {Line 32}

    if (!file_exists (DIRECTORY_CACHE)) {
    // give 777 permissions so that developer can overwrite
    // files created by web server user
    mkdir (DIRECTORY_CACHE);
    chmod (DIRECTORY_CACHE, 0777);
    }
    and check through address line in rowser, work fine with picture from external site.
    So problem is in function show_cache_file ($mime_type). I don't know why.

    Network theme and custom-functions.php do not support pictures in posts from external sites, and I hope that will be new feature in next release.

    I suggest to Network theme developer, for home page thumbnails that change code and support also pictures from external sites.

    I believe that using separate directories for temp thumbnail pictures for WP and WPMS/BP install is not necessary. timthumb.php can use uploads folder, with max num of pictures equal to num of featured post from home page.

    So there is a lot space for improvement.
    Finally, I'll try to make function for home page thumbnails similar with bp_activity_thumbnail_content_images( $content ) from BuddyPress.

    Keep in touch,
    Srecko

    msrecko

    Hello again,
    currently I've found solution which is ok for my site (http://blogge.rs).

    In customs-functions.php (in library/functions Network theme folder) between rows 575 and 588, I've made some changes, and now I do not use timthumb.php anymore.

    This is change only for multisite and Network blog posts option (similar changes you can made for Blog post).

    Code is:

    if ($homepage_show_thumbnails != "no") {

    switch_to_blog($blog);
    /// $thumbnail = get_image_path($thispost[0]->ID, $blog);

    $first_img = ''; /// new line
    $get_post_record = get_post($thispost[0]->ID); /// new line
    $output_pic_link = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $get_post_record->post_content, $matches); /// new line
    $first_img = $matches [1] [0]; /// new line

    restore_current_blog();

    ?>

    <?php if ($first_img != '') { ?>
    <img src="<?php echo $first_img; ?>" width="227" height="108"/>
    <?php } else if ($default_thumbnail_url != '') { ?>
    <div class="thumb">"><img src="<?php echo $default_thumbnail_url; ?>" alt="" /></div>
    <?php } ?>
    <?php }