Hooking a callback into the code within a Gutenberg block

I want to run some JavaScript when a user uploads an image or images using the core/image block or core/gallery block. Ideally I would run my own code when the onSelectImage function is called (and the equivalent for core/gallery). I’ve looked at hooks in Gutenberg but it seems that they’re only available in a small number of places, and there are none directly for the core/image or core/gallery blocks.

I know the developers intend to make it easy to apply actions and filters in Gutenberg, but I’m not sure if they just haven’t added any hooks/filters for the core/image block yet or if it’s already possible but I’m not seeing how to do it.

0

Leave a Comment