Skip to content

Commit

Permalink
Paste: fix blob uploading (#64479)
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix authored Aug 15, 2024
1 parent 8fc4c29 commit 1dfcd70
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 7 additions & 1 deletion packages/block-library/src/image/transforms.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* WordPress dependencies
*/
import { createBlobURL } from '@wordpress/blob';
import { createBlobURL, isBlobURL } from '@wordpress/blob';
import { createBlock, getBlockAttributes } from '@wordpress/blocks';
import { dispatch } from '@wordpress/data';
import { store as noticesStore } from '@wordpress/notices';
Expand Down Expand Up @@ -123,6 +123,12 @@ const transforms = {
anchor,
}
);

if ( isBlobURL( attributes.url ) ) {
attributes.blob = attributes.url;
delete attributes.url;
}

return createBlock( 'core/image', attributes );
},
},
Expand Down
6 changes: 5 additions & 1 deletion packages/block-library/src/video/transforms.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* WordPress dependencies
*/
import { createBlobURL } from '@wordpress/blob';
import { createBlobURL, isBlobURL } from '@wordpress/blob';
import { createBlock } from '@wordpress/blocks';

const transforms = {
Expand Down Expand Up @@ -92,6 +92,10 @@ const transforms = {
poster: videoElement.getAttribute( 'poster' ) || undefined,
src: videoElement.getAttribute( 'src' ) || undefined,
};
if ( isBlobURL( attributes.src ) ) {
attributes.blob = attributes.src;
delete attributes.src;
}
return createBlock( 'core/video', attributes );
},
},
Expand Down

0 comments on commit 1dfcd70

Please sign in to comment.