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 3c380d3dfe0125..d59d586eb04b4a 100644
--- a/packages/block-library/src/post-featured-image/dimension-controls.js
+++ b/packages/block-library/src/post-featured-image/dimension-controls.js
@@ -10,7 +10,11 @@ import {
__experimentalUseCustomUnits as useCustomUnits,
__experimentalToolsPanelItem as ToolsPanelItem,
} from '@wordpress/components';
-import { InspectorControls, useSettings } from '@wordpress/block-editor';
+import {
+ useSettings,
+ store as blockEditorStore,
+} from '@wordpress/block-editor';
+import { useSelect } from '@wordpress/data';
const SCALE_OPTIONS = (
<>
@@ -51,12 +55,25 @@ const DimensionControls = ( {
clientId,
attributes: { aspectRatio, width, height, scale, sizeSlug },
setAttributes,
- imageSizeOptions = [],
+ media,
} ) => {
const [ availableUnits ] = useSettings( 'spacing.units' );
const units = useCustomUnits( {
availableUnits: availableUnits || [ 'px', '%', 'vw', 'em', 'rem' ],
} );
+ const imageSizes = useSelect(
+ ( select ) => select( blockEditorStore ).getSettings().imageSizes,
+ []
+ );
+ const imageSizeOptions = imageSizes
+ .filter( ( { slug } ) => {
+ return media?.media_details?.sizes?.[ slug ]?.source_url;
+ } )
+ .map( ( { name, slug } ) => ( {
+ value: slug,
+ label: name,
+ } ) );
+
const onDimensionChange = ( dimension, nextValue ) => {
const parsedValue = parseFloat( nextValue );
/**
@@ -75,7 +92,7 @@ const DimensionControls = ( {
height || ( aspectRatio && aspectRatio !== 'auto' );
return (
-
+ <>
!! aspectRatio }
label={ __( 'Aspect ratio' ) }
@@ -230,7 +247,7 @@ const DimensionControls = ( {
/>
) }
-
+ >
);
};
diff --git a/packages/block-library/src/post-featured-image/edit.js b/packages/block-library/src/post-featured-image/edit.js
index 25133a2babcfc0..14e9bfdc74a87b 100644
--- a/packages/block-library/src/post-featured-image/edit.js
+++ b/packages/block-library/src/post-featured-image/edit.js
@@ -24,7 +24,6 @@ import {
MediaPlaceholder,
MediaReplaceFlow,
useBlockProps,
- store as blockEditorStore,
__experimentalUseBorderProps as useBorderProps,
__experimentalGetShadowClassesAndStyles as getShadowClassesAndStyles,
useBlockEditingMode,
@@ -132,19 +131,6 @@ export default function PostFeaturedImageEdit( {
const mediaUrl = getMediaSourceUrlBySizeSlug( media, sizeSlug );
- const imageSizes = useSelect(
- ( select ) => select( blockEditorStore ).getSettings().imageSizes,
- []
- );
- const imageSizeOptions = imageSizes
- .filter( ( { slug } ) => {
- return media?.media_details?.sizes?.[ slug ]?.source_url;
- } )
- .map( ( { name, slug } ) => ( {
- value: slug,
- label: name,
- } ) );
-
const blockProps = useBlockProps( {
style: { width, height, aspectRatio },
className: classnames( {
@@ -200,17 +186,21 @@ export default function PostFeaturedImageEdit( {
const controls = blockEditingMode === 'default' && (
<>
-
-
+
+
+
+
+
+
{
const { dimRatio } = attributes;
- const { gradientValue, setGradient } = __experimentalUseGradient();
+ const { gradientValue, setGradient } = useGradient();
const colorGradientSettings = useMultipleOriginColorsAndGradients();
if ( ! colorGradientSettings.hasColorsOrGradients ) {
@@ -31,7 +30,7 @@ const Overlay = ( {
}
return (
-
+ <>
-
+ >
);
};