Skip to content

Instantly share code, notes, and snippets.

@getdave
Created October 20, 2022 12:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save getdave/4e09439f2f0377ca23e354b7e8c535b2 to your computer and use it in GitHub Desktop.
Save getdave/4e09439f2f0377ca23e354b7e8c535b2 to your computer and use it in GitHub Desktop.
Get registered image sizes in the WordPress block editor
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