-
Notifications
You must be signed in to change notification settings - Fork 2
Labels
javascriptPull requests that update Javascript codePull requests that update Javascript code
Description
I've been using a variation of the following to convert an attachment ID to a URL:
function useMediaSrc( id ) {
const url = useSelect(
( select ) => {
const media = select( 'core' ).getMedia( id, { context: 'view' } );
if ( ! media ) {
return undefined;
}
return media.source_url;
},
[ id ]
);
return url;
}
It'd be good to have this in the hooks available
Metadata
Metadata
Assignees
Labels
javascriptPull requests that update Javascript codePull requests that update Javascript code