import { useState, useEffect } from '@wordpress/element'; import { MediaUpload, MediaUploadCheck } from '@wordpress/media-utils'; import { Button } from '@wordpress/components'; import apiFetch from '@wordpress/api-fetch'; const SUBTYPE_MAP = { image: 'image', video: 'video', document: 'application', all: '' }; const Thumbnail = ({ id, onRemove }) => { const [media, setMedia] = useState(null); useEffect(() => { let cancelled = false; if (!id) return; apiFetch({ path: `/wp/v2/media/${id}` }) .then((data) => !cancelled && setMedia(data)) .catch(() => {}); return () => { cancelled = true; }; }, [id]); const thumb = media?.media_details?.sizes?.thumbnail?.source_url || media?.source_url; const isImage = media?.media_type === 'image'; return (
{field.label}