Hey everyone,
I’m having an issue with a script that I use rather frequently as a TimThumb alternative. It works great for 99% of the themes, but I’ve received in one case an error that I don’t know quite how to solve.
“Catchable fatal error: Object of class WP_Error could not be converted to string”
Referring to line:
$new_img_size = getimagesize( $new_img_path );
I seem to recall another discussion (can’t find it) on the boards about this particular script, and several mentioned they use it frequently. Here’s the script link:
http://core.trac.wordpress.org/ticket/15311Any advice what the error is referring to or how to go about solving it would be great!
Thanks!
- Envato Staff
- Sold between 100 000 and 250 000 dollars
- Support Staff
- United States
- Author had a Free File of the Month
- Microlancer Beta Tester
- Beta Tester
- Interviewed on the Envato Notes blog
I seem to recall having an issue with this in the (far) past once and if I recall, the problem was because the user had set a different image upload folder path than the WP default:
http://cl.ly/390p1s2V2d2L1q1j3U3XLooks like they have the default settings in place. It’s a strange problem, I guess. Thanks for your help, Jami.
Siiimple said
“Catchable fatal error: Object of class WP_Error could not be converted to string”Referring to line:
$new_img_size = getimagesize( $new_img_path );
the problem comes from previous line:
$new_img_path = image_resize( $file_path, $width, $height, $crop );
$new_img_size = getimagesize( $new_img_path );
the image_resize function requires GD Library to be installed in your server.
ask your buyer to contact his hosting support to activate GD Library on his server.
Thanks, I’ll see if that’s the issue.
Appreciate your help!
I used this script too, but had some issues regarding $_SERVER['DOCUMENT_ROOT'] variable. Lately I figured out that there is two lines commented out (the last two lines) ...
$file_path = parse_url( $img_url );
$file_path = $_SERVER['DOCUMENT_ROOT'] . $file_path['path'];
// Look for Multisite Path
if(file_exists($file_path) === false){
global $blog_id;
$file_path = parse_url( $img_url );
if (preg_match("/files/", $file_path['path'])) {
$path = explode('/',$file_path['path']);
foreach($path as $k=>$v){
if($v == 'files'){
$path[$k-1] = 'wp-content/blogs.dir/'.$blog_id;
}
}
$path = implode('/',$path);
}
$file_path = $_SERVER['DOCUMENT_ROOT'].$path;
}
//$file_path = ltrim( $file_path['path'], '/' );
//$file_path = rtrim( ABSPATH, '/' ).$file_path['path'];
I see that these two lines are not grayed out in the latest version of the script, I’m not sure if they should solve $_SERVER['DOCUMENT_ROOT'] issue. Do you have any idea?
Sorry, not very experienced in PHP !
Well, the journey continues on.
The client said they double check that GD Library was installed, so I guess that’s not the issue.
Not sure about the two grayed out lines. I tried to activate them, but that didn’t seem to do anything.
Do you use the latest version of the script? I it’s this … https://gist.github.com/930234/5d5ba6a426c4981c6648098d68554ca0f93127c4
I’m also not sure what to use, TimThumb or this script ( vt_resize ), the only downside is the DOCUMENT _ROOT variable issue! but I think it’s resolved.
- Envato Staff
- Sold between 100 000 and 250 000 dollars
- Support Staff
- United States
- Author had a Free File of the Month
- Microlancer Beta Tester
- Beta Tester
- Interviewed on the Envato Notes blog
Just out curiosity, do they have WordPress installed on a subdomain or something other than a top level folder? Also, are they using a WordPress MU installation?
I checked, and it’s installed in the root domain. No, they’re not MU. The script was working fine for several months, but then just donked out. The error keeps pointing to:
$new_img_path = image_resize( $actual_file_path, $width, $height, $crop ); $new_img_size = getimagesize( $new_img_path ); $new_img = str_replace( basename( $image_src[0] ), basename( $new_img_path ), $image_src[0] );
Catchable fatal error: Object of class WP_Error could not be converted to string line 209
