From 2e5ab67fea0367adf4c6b9f36735453c2c785ff6 Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Wed, 4 Mar 2026 10:11:15 +0400 Subject: [PATCH] Image: Replace 'getEntityRecordPermissions` with 'canUser' Use the public 'canUser' selector instead of the private 'getEntityRecordPermissions'. Gate the check on 'imageRecord' availability to avoid fetching permissions before the record is loaded. --- packages/block-library/src/image/image.js | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/packages/block-library/src/image/image.js b/packages/block-library/src/image/image.js index 9209b66ace91de..ae76193f20f9b0 100644 --- a/packages/block-library/src/image/image.js +++ b/packages/block-library/src/image/image.js @@ -323,20 +323,15 @@ export default function Image( { ) : null; - // Check edit permissions. When the media editor experiment is enabled, - // use getEntityRecordPermissions which checks via canUser API. - // Only check when the image is selected to avoid unnecessary API requests. + // Check edit permissions when the media editor experiment is enabled. + // Only check when imageRecord is available to avoid unnecessary API requests. let canEdit = false; - if ( id && isSingleSelected && window?.__experimentalMediaEditor ) { - const { getEntityRecordPermissions } = unlock( - select( coreStore ) - ); - const permissions = getEntityRecordPermissions( - 'postType', - 'attachment', - id - ); - canEdit = permissions?.update || false; + if ( imageRecord && window?.__experimentalMediaEditor ) { + canEdit = !! select( coreStore ).canUser( 'update', { + kind: 'postType', + name: 'attachment', + id, + } ); } return {