From 6111506a41f5f36872e9df113f20ef217b574daa Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Wed, 25 Dec 2024 15:25:21 +0400 Subject: [PATCH 1/2] Post Featured Image: Use the 'ResolutionTool' component --- .../post-featured-image/dimension-controls.js | 38 ++++++++----------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/packages/block-library/src/post-featured-image/dimension-controls.js b/packages/block-library/src/post-featured-image/dimension-controls.js index 5a3e40a126bf8..7cf75114fd0ea 100644 --- a/packages/block-library/src/post-featured-image/dimension-controls.js +++ b/packages/block-library/src/post-featured-image/dimension-controls.js @@ -12,10 +12,18 @@ import { } from '@wordpress/components'; import { useSettings, + privateApis as blockEditorPrivateApis, store as blockEditorStore, } from '@wordpress/block-editor'; import { useSelect } from '@wordpress/data'; +/** + * Internal dependencies + */ +import { unlock } from '../lock-unlock'; + +const { ResolutionTool } = unlock( blockEditorPrivateApis ); + const SCALE_OPTIONS = ( <> ) } { !! imageSizeOptions.length && ( - !! sizeSlug } - label={ __( 'Resolution' ) } - onDeselect={ () => - setAttributes( { sizeSlug: undefined } ) + + setAttributes( { sizeSlug: nextSizeSlug } ) } - resetAllFilter={ () => ( { - sizeSlug: undefined, - } ) } isShownByDefault={ false } - panelId={ clientId } - > - - setAttributes( { sizeSlug: nextSizeSlug } ) - } - help={ __( 'Select the size of the source image.' ) } - /> - + /> ) } ); From ef8e2e92d94a623d242bd9f5d5a1f089654160d5 Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Wed, 25 Dec 2024 17:31:35 +0400 Subject: [PATCH 2/2] Fix 'Reset all' action --- .../src/post-featured-image/dimension-controls.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/block-library/src/post-featured-image/dimension-controls.js b/packages/block-library/src/post-featured-image/dimension-controls.js index 7cf75114fd0ea..9a71a96b2db84 100644 --- a/packages/block-library/src/post-featured-image/dimension-controls.js +++ b/packages/block-library/src/post-featured-image/dimension-controls.js @@ -240,6 +240,9 @@ const DimensionControls = ( { setAttributes( { sizeSlug: nextSizeSlug } ) } isShownByDefault={ false } + resetAllFilter={ () => ( { + sizeSlug: DEFAULT_SIZE, + } ) } /> ) }