Created
October 20, 2022 12:19
-
-
Save getdave/4e09439f2f0377ca23e354b7e8c535b2 to your computer and use it in GitHub Desktop.
Get registered image sizes in the WordPress block editor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {store as blockEditorStore } from '@wordpress/block-editor'; | |
import { useSelect } from "@wordpress/data"; | |
// Inside component | |
const {sizes} = useSelect((select) => { | |
const { getSettings } = select(blockEditorStore); | |
const settings = getSettings(); | |
const sizes = settings?.imageEditing?.imageSizes; | |
return { | |
sizes | |
}; | |
}, []); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment