Skip to content

Commit fe054f7

Browse files
authored
Image Block: Add window to the optional chaining (#40394)
* Add window to the optional chaining * Image block: Remove the global wp
1 parent 53977c6 commit fe054f7

File tree

1 file changed

+2
-4
lines changed
  • packages/block-library/src/image

1 file changed

+2
-4
lines changed

packages/block-library/src/image/edit.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ import { useEffect, useRef, useState } from '@wordpress/element';
2222
import { __ } from '@wordpress/i18n';
2323
import { image as icon } from '@wordpress/icons';
2424

25-
/* global wp */
26-
2725
/**
2826
* Internal dependencies
2927
*/
@@ -97,7 +95,7 @@ function hasDefaultSize( image, defaultSize ) {
9795
* @return {boolean} Whether the image has been destroyed.
9896
*/
9997
export function isMediaDestroyed( id ) {
100-
const attachment = wp?.media?.attachment( id ) || {};
98+
const attachment = window?.wp?.media?.attachment( id ) || {};
10199
return attachment.destroyed;
102100
}
103101

@@ -232,7 +230,7 @@ export function ImageEdit( {
232230
// The constants used in Gutenberg do not match WP options so a little more complicated than ideal.
233231
// TODO: fix this in a follow up PR, requires updating media-text and ui component.
234232
switch (
235-
wp?.media?.view?.settings?.defaultProps?.link ||
233+
window?.wp?.media?.view?.settings?.defaultProps?.link ||
236234
LINK_DESTINATION_NONE
237235
) {
238236
case 'file':

0 commit comments

Comments
 (0)