Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: removed

GutenbergKit: disable problematic media providers.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Button, MenuItem, MenuGroup, Dropdown, NavigableMenu } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { Icon, media } from '@wordpress/icons';
import { isGutenbergKit } from '../utils/is-gutenberg-kit';
import { isSupportNext40pxDefaultSize } from '../utils/is-support-next-40px-default-size';
import MediaSources from './media-sources';

Expand All @@ -13,6 +14,13 @@ function MediaButtonMenu( props ) {
const { mediaProps, open, setSelectedSource, isFeatured, isReplace, hasImage } = props;
const originalComponent = mediaProps.render;

// Disable the media button menu for GutenbergKit (mobile app) as the APIs for
// the external media sources do not currently support GutenbergKit's token
// authentication and CORS requests.
if ( isGutenbergKit() ) {
return originalComponent( { open } );
}

if ( isReplace ) {
return (
<MediaSources
Expand Down
8 changes: 7 additions & 1 deletion projects/packages/external-media/src/shared/sources/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
SOURCE_JETPACK_AI_GENERAL_PURPOSE_IMAGE_FOR_MEDIA_SOURCE,
SOURCE_JETPACK_AI_GENERAL_PURPOSE_IMAGE_FOR_BLOCK,
} from '../constants';
import { isGutenbergKit } from '../utils/is-gutenberg-kit';
import GooglePhotosMedia from './google-photos';
import JetpackAIFeaturedImage from './jetpack-ai-featured-image';
import JetpackAIGeneralPurposeImageForBlock from './jetpack-ai-general-purpose-image-for-block';
Expand All @@ -24,7 +25,7 @@ import JetpackAppMedia from './jetpack-app-media';
import OpenverseMedia from './openverse';
import PexelsMedia from './pexels';

export const internalMediaSources = [
const allInternalMediaSources = [
{
id: SOURCE_JETPACK_APP_MEDIA,
label: __( 'Your Phone', 'jetpack-external-media' ),
Expand All @@ -33,6 +34,11 @@ export const internalMediaSources = [
},
];

// Disable SOURCE_JETPACK_APP_MEDIA for GutenbergKit (mobile app) as sourcing
// media from "Your phone" while on a phone is less useful and possibly
// confusing.
export const internalMediaSources = isGutenbergKit() ? [] : allInternalMediaSources;

/**
* Used when the context is for a featured image.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Check if the editor is running in a GutenbergKit (mobile app) environment.
*
* @return {boolean} True if running in GutenbergKit, false otherwise.
*/
export const isGutenbergKit = () => {
return !! window?.GBKit;
};
Loading