Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Restore all filter props
  • Loading branch information
Mamaduka committed Apr 28, 2022
commit bf9badab8c1d7ba0f7f357469c2463f1f33cf5ab
43 changes: 30 additions & 13 deletions packages/editor/src/components/post-featured-image/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function PostFeaturedImage( {
currentPostId
);

function onDropImage( filesList ) {
function onDropFiles( filesList ) {
mediaUpload( {
allowedTypes: [ 'image' ],
filesList,
Expand Down Expand Up @@ -204,7 +204,7 @@ function PostFeaturedImage( {
( postLabel.set_featured_image ||
DEFAULT_SET_FEATURE_IMAGE_LABEL ) }
</Button>
<DropZone onFilesDrop={ onDropImage } />
<DropZone onFilesDrop={ onDropFiles } />
</div>
) }
value={ featuredImageId }
Expand Down Expand Up @@ -262,17 +262,34 @@ const applyWithSelect = withSelect( ( select ) => {
};
} );

const applyWithDispatch = withDispatch( ( dispatch ) => {
const { editPost } = dispatch( editorStore );
return {
onUpdateImage( image ) {
editPost( { featured_media: image?.id } );
},
onRemoveImage() {
editPost( { featured_media: 0 } );
},
};
} );
const applyWithDispatch = withDispatch(
( dispatch, { noticeOperations }, { select } ) => {
const { editPost } = dispatch( editorStore );
return {
onUpdateImage( image ) {
editPost( { featured_media: image.id } );
},
onDropImage( filesList ) {
select( blockEditorStore )
.getSettings()
.mediaUpload( {
allowedTypes: [ 'image' ],
filesList,
onFileChange( [ image ] ) {
editPost( { featured_media: image.id } );
},
onError( message ) {
noticeOperations.removeAllNotices();
noticeOperations.createErrorNotice( message );
},
} );
},
onRemoveImage() {
editPost( { featured_media: 0 } );
},
};
}
);

export default compose(
withNotices,
Expand Down