Skip to content

Instantly share code, notes, and snippets.

@leurdo
Created October 17, 2022 15:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leurdo/bfbcac57ee963f3874268421b509409c to your computer and use it in GitHub Desktop.
Save leurdo/bfbcac57ee963f3874268421b509409c to your computer and use it in GitHub Desktop.
gutenberg: make srset from media object
import { get } from 'lodash';
import { select, useSelect } from '@wordpress/data';
const image = useSelect( () => select( 'core' ).getMedia( id ) );
const thumbnail = get( image, [ 'media_details', 'sizes', 'medium', 'source_url' ] );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment