diff --git a/projects/packages/publicize/_inc/components/media-section-v2/icons/sparkle.tsx b/projects/packages/publicize/_inc/components/media-section-v2/icons/sparkle.tsx
new file mode 100644
index 000000000000..6b30eaa54a84
--- /dev/null
+++ b/projects/packages/publicize/_inc/components/media-section-v2/icons/sparkle.tsx
@@ -0,0 +1,10 @@
+const sparkle = (
+
+);
+
+export default sparkle;
diff --git a/projects/packages/publicize/_inc/components/media-section-v2/index.tsx b/projects/packages/publicize/_inc/components/media-section-v2/index.tsx
index cc59e85db26b..505b32ead962 100644
--- a/projects/packages/publicize/_inc/components/media-section-v2/index.tsx
+++ b/projects/packages/publicize/_inc/components/media-section-v2/index.tsx
@@ -11,7 +11,6 @@ import { BaseControl, Button, ExternalLink } from '@wordpress/components';
import { useCallback, useMemo, useReducer, useRef } from '@wordpress/element';
import { applyFilters } from '@wordpress/hooks';
import { __ } from '@wordpress/i18n';
-import clsx from 'clsx';
import useFeaturedImage from '../../hooks/use-featured-image';
import useImageGeneratorConfig from '../../hooks/use-image-generator-config';
import useMediaDetails from '../../hooks/use-media-details';
@@ -395,38 +394,37 @@ export default function MediaSectionV2( {
render={ renderMediaUpload }
/>
- { /* Show dropdown + preview when there's media */ }
+ { /* Show preview + dropdown when there's media */ }
{ previewData && (
<>
-
- { ( { open } ) => (
-
- ) }
-
- { currentSource === 'sig' && (
-
+
-
- { media &&
- ! isLoading &&
- ( media.type === 'video' ? (
-
- ) : (
-

- ) ) }
- { isLoading &&
}
-
- { ( media || isLoading ) && (
-
-
- { showRemove && (
-
- ) }
-
- ) }
+
+ { media &&
+ ! isLoading &&
+ ( media.type === 'video' ? (
+
+ ) : (
+

+ ) ) }
+ { isLoading &&
}
);
}
diff --git a/projects/packages/publicize/_inc/components/media-section-v2/media-source-menu.tsx b/projects/packages/publicize/_inc/components/media-section-v2/media-source-menu.tsx
index e60cb973146e..50b6088c1af8 100644
--- a/projects/packages/publicize/_inc/components/media-section-v2/media-source-menu.tsx
+++ b/projects/packages/publicize/_inc/components/media-section-v2/media-source-menu.tsx
@@ -3,7 +3,7 @@
* Displays a dropdown menu with grouped media source options
*/
-import { Button, Dropdown, MenuGroup } from '@wordpress/components';
+import { Button, Dropdown, MenuGroup, MenuItem } from '@wordpress/components';
import { useCallback, useMemo } from '@wordpress/element';
import { __, _x } from '@wordpress/i18n';
import MediaSourceMenuItem from './media-source-menu-item';
@@ -11,6 +11,38 @@ import styles from './styles.module.scss';
import { MediaSourceMenuProps } from './types';
import { getMediaSourceOptions } from './utils/media-source-options';
+/**
+ * Menu item for clearing media selection.
+ *
+ * @param {object} root0 - Component props.
+ * @param {boolean} root0.isSelected - Whether this option is currently active.
+ * @param {Function} root0.onRemove - Callback to clear media.
+ * @param {Function} root0.onClose - Callback to close the dropdown.
+ * @return {JSX.Element} NoMediaMenuItem component.
+ */
+function NoMediaMenuItem( {
+ isSelected,
+ onRemove,
+ onClose,
+}: {
+ isSelected: boolean;
+ onRemove?: () => void;
+ onClose: () => void;
+} ) {
+ const handleClick = useCallback( () => {
+ onRemove?.();
+ onClose();
+ }, [ onRemove, onClose ] );
+
+ return (
+
+
+
+ );
+}
+
/**
* MediaSourceMenu component
*
@@ -24,15 +56,19 @@ export default function MediaSourceMenu( {
onAiImageClick,
disabled = false,
featuredImageId,
+ onRemove,
children,
}: MediaSourceMenuProps ) {
// Get options from function to ensure translations are loaded
const options = useMemo( () => getMediaSourceOptions(), [] );
- // Group options by category
+ // Group options by category, hiding "Featured image" when no featured image exists
const linkPreviewOptions = useMemo(
- () => options.filter( opt => opt.group === 'link-preview' ),
- [ options ]
+ () =>
+ options.filter(
+ opt => opt.group === 'link-preview' && ( opt.id !== 'featured-image' || featuredImageId )
+ ),
+ [ options, featuredImageId ]
);
const attachmentOptions = useMemo(
() => options.filter( opt => opt.group === 'attachment' ),
@@ -44,6 +80,7 @@ export default function MediaSourceMenu( {
<>
{ ! children && (