Media Upload Directory Issue
-
Hi
I have thumbnail image issue
Can you help me with this?
https://prnt.sc/nq5svlThank you in advance
/** * Upload User File. * * @param [type] $file video url. * @param [type] $post_id Post id. */ function king_upload_user_file( $file = array(), $post_id ) { require_once ABSPATH . 'wp-admin/includes/admin.php'; $file_return = wp_handle_upload( $file, array( 'test_form' => false ) ); if ( isset( $file_return['error'] ) || isset( $file_return['upload_error_handler'] ) ) { return false; } else { $filename = $file_return['file']; $attachment = array( 'post_mime_type' => $file_return['type'], 'post_content' => '', 'post_type' => 'attachment', 'post_status' => 'inherit', 'guid' => $file_return['url'], ); $attachment_id = wp_insert_attachment( $attachment, $file_return['url'], $post_id ); require_once( ABSPATH . 'wp-admin/includes/image.php' ); $attachment_data = wp_generate_attachment_metadata( $attachment_id, $filename ); wp_update_attachment_metadata( $attachment_id, $attachment_data ); if ( 0 < intval( $attachment_id ) ) { return $attachment_id; } } return false; }
The page I need help with: [log in to see the link]
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Media Upload Directory Issue’ is closed to new replies.