I'm attempting to generate a thumbnail for an image I have posted, but it seems when I call image_downsize, the index[0] actually prints an array as the URL. I'm a bit confused, so any help would be appreciated!
My code:
$wpUploadPath = wp_upload_dir();
$target_path = $wpUploadPath;
$filename = 'http://www.mysite.org/uploads/sampleFile.jpeg';
$fileNameFinal = pathinfo($filename);
$wp_filetype = wp_check_filetype($filename, null);
$attachment = array(
'post_mime_type' => $wp_filetype['type'],
'post_title' => $fileNameFinal['filename'],
'post_content' => '',
'post_status' => 'inherit'
);
$attach_id = wp_insert_attachment( $attachment, $target_path);
$upFile = image_downsize( $attach_id, 'thumbnail' );
Here is where I encounter the problem. If I print_r($upFile);
I get:
Array (
[0] => http://www.mysite.org/uploads/Array
[1] => 0
[2] => 0
[3] =>
)
Is this normal? I can't seem to generate the thumbnail to update my user meta's with this.
Any help would be appreciated. Thanks!
Tre