@@ -19,7 +19,7 @@ import {
19
19
store as blockEditorStore ,
20
20
} from '@wordpress/block-editor' ;
21
21
import { useEffect , useRef , useState } from '@wordpress/element' ;
22
- import { __ , sprintf } from '@wordpress/i18n' ;
22
+ import { __ } from '@wordpress/i18n' ;
23
23
import { image as icon } from '@wordpress/icons' ;
24
24
25
25
/**
@@ -85,20 +85,6 @@ function hasDefaultSize( image, defaultSize ) {
85
85
) ;
86
86
}
87
87
88
- /**
89
- * Checks if a media attachment object has been "destroyed",
90
- * that is, removed from the media library. The core Media Library
91
- * adds a `destroyed` property to a deleted attachment object in the media collection.
92
- *
93
- * @param {number } id The attachment id.
94
- *
95
- * @return {boolean } Whether the image has been destroyed.
96
- */
97
- export function isMediaDestroyed ( id ) {
98
- const attachment = window ?. wp ?. media ?. attachment ( id ) || { } ;
99
- return attachment . destroyed ;
100
- }
101
-
102
88
export function ImageEdit ( {
103
89
attributes,
104
90
setAttributes,
@@ -139,41 +125,6 @@ export function ImageEdit( {
139
125
return pick ( getSettings ( ) , [ 'imageDefaultSize' , 'mediaUpload' ] ) ;
140
126
} , [ ] ) ;
141
127
142
- // A callback passed to MediaUpload,
143
- // fired when the media modal closes.
144
- function onCloseModal ( ) {
145
- if ( isMediaDestroyed ( attributes ?. id ) ) {
146
- setAttributes ( {
147
- url : undefined ,
148
- id : undefined ,
149
- } ) ;
150
- }
151
- }
152
-
153
- /*
154
- Runs an error callback if the image does not load.
155
- If the error callback is triggered, we infer that that image
156
- has been deleted.
157
- */
158
- function onImageError ( isReplaced = false ) {
159
- noticeOperations . removeAllNotices ( ) ;
160
- noticeOperations . createErrorNotice (
161
- sprintf (
162
- /* translators: %s url or missing image */
163
- __ ( 'Error loading image: %s' ) ,
164
- url
165
- )
166
- ) ;
167
- // If the image block was not replaced with an embed,
168
- // clear the attributes and trigger the placeholder.
169
- if ( ! isReplaced ) {
170
- setAttributes ( {
171
- url : undefined ,
172
- id : undefined ,
173
- } ) ;
174
- }
175
- }
176
-
177
128
function onUploadError ( message ) {
178
129
noticeOperations . removeAllNotices ( ) ;
179
130
noticeOperations . createErrorNotice ( message ) ;
@@ -372,8 +323,6 @@ export function ImageEdit( {
372
323
containerRef = { ref }
373
324
context = { context }
374
325
clientId = { clientId }
375
- onCloseModal = { onCloseModal }
376
- onImageLoadError = { onImageError }
377
326
/>
378
327
) }
379
328
{ ! url && (
@@ -390,7 +339,6 @@ export function ImageEdit( {
390
339
onSelectURL = { onSelectURL }
391
340
notices = { noticeUI }
392
341
onError = { onUploadError }
393
- onClose = { onCloseModal }
394
342
accept = "image/*"
395
343
allowedTypes = { ALLOWED_MEDIA_TYPES }
396
344
value = { { id, src } }
0 commit comments