Я пытаюсь импортировать изображения программно с помощью cron в WordPress.В веб-интерфейсе проблем нет, но в бэкенде имеются миниатюры ширины: 1 пикселя, высоты: 1 пикселя, например
<img src="" class="attachment-130x130 size-130x130 wp-post-image" alt="" width="1" height="1">
Мой код
if (@fclose(@fopen($file_url, "r"))) { //make sure the file actually exists
copy($file_url, ABSPATH.$artDir.$new_filename);
$siteurl = get_option('siteurl');
$file_info = getimagesize(ABSPATH.$artDir.$new_filename);
$artdata = array(
'post_author' => 1,
'post_date' => current_time('mysql'),
'post_date_gmt' => current_time('mysql'),
'post_title' => $new_filename,
'post_status' => 'inherit',
'comment_status' => 'closed',
'ping_status' => 'closed',
'post_name' => sanitize_title_with_dashes(str_replace("_", "-", $new_filename)),
'post_modified' => current_time('mysql'),
'post_modified_gmt' => current_time('mysql'),
'post_parent' => $post_id,
'post_type' => 'attachment',
'guid' => $siteurl.'/'.$artDir.$new_filename,
'post_mime_type' => $file_info['mime'],
'post_excerpt' => $new_filename,
'post_content' => $new_filename
);
$save_path = $artDir . $new_filename;
//insert the database record
$attach_id = wp_insert_attachment( $artdata, $save_path, $post_id );
// apply filters (important in some environments)
$file_type = wp_check_filetype(basename($file_url), null);
apply_filters('wp_handle_upload', array('file' => $save_path, 'url' => $file_url, 'type' => $file_type), 'upload');
wp_set_post_tags( $attach_id, 'property', true );
//generate metadata and thumbnails
if ($attach_data = wp_generate_attachment_metadata( $attach_id, $save_path)) {
wp_update_attachment_metadata($attach_id, $attach_data);
}
$guid = $siteurl . $artDir . $new_filename;
}
У вас есть идея, почему?спасибо.