Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate Pexels and Google Images to Gutenberg media sidebar #71232

Closed
4 tasks done
simison opened this issue Dec 15, 2022 · 13 comments
Closed
4 tasks done

Integrate Pexels and Google Images to Gutenberg media sidebar #71232

simison opened this issue Dec 15, 2022 · 13 comments
Assignees
Labels
[Goal] Gutenberg Working towards full integration with Gutenberg

Comments

@simison
Copy link
Member

simison commented Dec 15, 2022

Gutenberg (since 14.7) has a new "media" tab in the inserter sidebar:

Since then, the sidebar also has OpenVerse available.

It would be good to add WP.com's Google Photos and Pexels media sources to this sidebar.

Currently those image sources are available in the media block:

Media block Media modal

The "calypso media modal" which will stop functioning in the editor as 3rd party cookie support goes away, and once we finally remove the Calypso-Gutenberg iframe:

VideoPress doesn't currently play with the sidebar, it's on their radar but isn't being worked on however they have carried out a useful exploration - pe4Cmx-LC-p2. We don't need to work on this but we do need to be aware that they (and other unknown third parties) will follow our footsteps.

Next steps:

  • Open/find an issue in GB repo about making the sidebar extensible
  • Review any existing proposals, or create a new one for how extension could work - do this in the open
  • Open a PR adding extension points
  • Add Pexels and gphotos extensions to wpcom (or calypso/jetpack etc)
@simison simison added the [Goal] Gutenberg Working towards full integration with Gutenberg label Dec 15, 2022
@ianstewart
Copy link
Contributor

On .com there's currently some integration problem as the tab doesn't show up.

Looks like this part works now at least.

@simison
Copy link
Member Author

simison commented Apr 11, 2023

VideoPress is experimenting with the sidebar too pe4Cmx-LC-p2

@dsas
Copy link
Contributor

dsas commented May 9, 2023

@dsas
Copy link
Contributor

dsas commented Jun 12, 2023

The VideoPress P2 linked above explains roughly what we need to do, though it looks like adding to inserterMediaCategories is still not possible - it's a private/experimental setting. @ntsekouras are there any plans to change this? Is there anything that we could do to help?

@ntsekouras
Copy link
Member

Definitely we need to make an API for that, but right now we're very close to the new WP release. We should start working on this early to be definitely ready for the next one.

@ntsekouras
Copy link
Member

It's a long shot to have it ready in just a few days for 6.3, but I opened a PR about making the media categories extensible. I'd appreciate some testing there if any of you find some time 😄

@simison
Copy link
Member Author

simison commented Jun 16, 2023

WP.com runs Gutenberg for all sites so it'd be fine if it's not in 6.3 yet?

@ntsekouras
Copy link
Member

WP.com runs Gutenberg for all sites so it'd be fine if it's not in 6.3 yet?

Oh, that's great then!

@dsas
Copy link
Contributor

dsas commented Jun 20, 2023

Uploaded @ntsekouras PR to my wpcom sandbox and from the wp-admin editor I'm now able to run some hacked together pexels fetch

wp.blockEditor.registerInserterMediaCategory( {
	name: 'pexel13',
	labels: {
		name: 'Pexels13',
        
	},
	mediaType: 'image',
	async fetch( query = {} ) {
		// /wpcom/v2/sites/216813947/external-media/list/pexels?_envelope=1&number=20&path=recent&search=mountain&_gutenberg_nonce=de7555b5f0&_locale=user

		const url = 'https://public-api.wordpress.com/wpcom/v2/sites/216813947/external-media/list/pexels?_envelope=1&number=20&path=recent&search=mountain&_locale=user';
	
		const response = await wp.apiFetch( {url: url} );
		const results = response.media;
		return results.map( ( result ) => ( {
			...result,
			// If your response result includes an `id` prop that you want to access later, it should
			// be mapped to `InserterMediaItem`'s `sourceId` prop. This can be useful if you provide
			// a report URL getter.
			// Additionally you should always clear the `id` value of your response results because
			// it is used to identify WordPress media items.
			sourceId: result.ID,
			id: undefined,
			caption: result.caption,
			previewUrl: result.thumbnails.thumbnail,
			url: result.URL
		} ) );
	},
	getReportUrl: null,
	isExternalResource: true,
} );

and it works!

There's something going on with jetpack-layout-grid that I need to investigate, but I assume that's to do with a different gb trunk change, not Nik's diff

@dsas
Copy link
Contributor

dsas commented Jun 20, 2023

The current pexels code lives in jetpack we will have to see how we can extract stuff to supply the fetch function for the inserter sidebar API.

@rcrdortiz rcrdortiz self-assigned this Jul 7, 2023
@rcrdortiz
Copy link
Contributor

Updated the end date since we haven't been working on this because we needed to work on the GS on personal plans A/B test project.

@rcrdortiz
Copy link
Contributor

Referencing this issue since they share the same requirements.

@rcrdortiz
Copy link
Contributor

We've now released these changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Goal] Gutenberg Working towards full integration with Gutenberg
Projects
None yet
Development

No branches or pull requests

5 participants