wp_generate_attachment_metadata returns empty array
-
Hello,
I receive a empty array when i use wp_generate_attachment_metadata and this function do not generates the intermediate images.
I am adding images using wp_handle_uploads and this works fine. This generates a attach_id that I use with the function wp_generate_attachment_metadata.
I get no errors or warnings in the error_reporting log.I am using WMPU(multisite) wordpress and I no longer know what to do…
$i=0; $imgpath =wp_upload_dir(); require_once( ABSPATH . 'wp-admin/includes/image.php' ); foreach ($images as $key) { //$images[] <-- images url in the default upload dir if($key == 'error')continue; $path = $imgpath['path'].'/'.basename($key); $attachment = array( 'guid' => $key, //url 'post_mime_type' => image_type_to_mime_type(exif_imagetype($key)), 'post_title' => sanitize_file_name(basename($key)), 'post_content' => '', 'post_status' => 'inherit' ); $attach_id = wp_insert_attachment( $attachment,$path, $pid ); $attach_dat = wp_generate_attachment_metadata( $attach_id, $path); if(!empty($attach_dat))wp_update_attachment_metadata($attach_id, $attach_dat); if($i==0) set_post_thumbnail( $pid, $attach_id ); $i++; }
That was coded in a non template-file, where i load WP with
require_once($_SERVER['DOCUMENT_ROOT']."/test/site0/wp-config.php");
I not sure it influences in something.
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘wp_generate_attachment_metadata returns empty array’ is closed to new replies.