Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions packages/editor/src/utils/media-upload/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,24 @@ export default function mediaUpload( {
onError = noop,
onFileChange,
} ) {
const { getCurrentPostId, getEditorSettings } = select( editorStore );
const { getCurrentPost, getEditorSettings } = select( editorStore );
const wpAllowedMimeTypes = getEditorSettings().allowedMimeTypes;
maxUploadFileSize =
maxUploadFileSize || getEditorSettings().maxUploadFileSize;
const currentPostId = getCurrentPostId();
const currentPost = getCurrentPost();
// Templates and template parts' numerical ID is stored in `wp_id`.
const currentPostId =
typeof currentPost?.id === 'number'
? currentPost.id
: currentPost?.wp_id;
const postData = currentPostId ? { post: currentPostId } : {};

uploadMedia( {
allowedTypes,
filesList,
onFileChange,
additionalData: {
...( ! isNaN( currentPostId ) ? { post: currentPostId } : {} ),
...postData,
...additionalData,
},
maxUploadFileSize,
Expand Down