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

Add the Openverse Media Library #375

Merged
merged 18 commits into from
Dec 2, 2021
Merged

Add the Openverse Media Library #375

merged 18 commits into from
Dec 2, 2021

Conversation

ryelle
Copy link
Contributor

@ryelle ryelle commented Nov 10, 2021

Fixes #37 — Add a modal for searching the Openverse collection of images. Built on top of #373.

This is a rough draft of a search interface for finding images from Openverse. The only working test case is the Image block (other blocks use slightly different flows).

In the following recording, I've added an image block, found and selected an image, replaced the image, then re-replaced the image using the keyboard only.

Screen.Recording.2021-11-10.at.11.46.06.AM.mov

Steps to finish this PR:

  • Check that the "openverse image object to block image object" conversion is okay
  • Check if we need OAuth to run searches on openverse API
  • Use the OAuth flow for API requests Openverse: Add endpoint to proxy search requests with authentication #382 (marking complete since it's not a blocker for this PR, either can go in first)
  • Make the image selection work with other image blocks: Gallery, Cover, Media & Text
  • Get something in place for non-image media blocks: Audio, Video, File (eventually will be supported in Openverse, but not yet)
  • Accessibility — currently this is using buttons, but the images have no alt text or displayed title, so keyboard-only selection works but not screen readers. Will also need a different selection method when selecting a gallery, maybe an extra button to "Select" the image(s) like the core media modal? (IMO following the core structure here is probably best, as it's been tested and proven already)
  • Design help in general 😅

Screenshots

Open the modal, shows a request to get all images. Here we could prepopulate a search term, or make some other specific request.
media-all

Type in the search bar, returns the results
media-search

If there are no results, we show an empty state
media-no-results

@ryelle ryelle added [Component] Pattern Creator Anything related to the pattern front end editor or preview [Status] Needs Design labels Nov 10, 2021
@ryelle ryelle added this to the Pattern Creation milestone Nov 10, 2021
@ryelle ryelle self-assigned this Nov 10, 2021
@ryelle ryelle changed the base branch from trunk to update/restricted-media-library November 11, 2021 20:00
@ryelle ryelle force-pushed the try/openverse-media-gallery branch from 55b2319 to 66f6515 Compare November 11, 2021 20:02
@ryelle
Copy link
Contributor Author

ryelle commented Nov 15, 2021

The latest commits add support for Gallery selection too, and now uses the 2-step process that the core media modal does - you first select an image (which is highlighted with a blue border), then "Add media" in the modal footer. Still tweaking the keyboard interaction, I think the whole grid will be a single tab stop, with arrow keys to select.

Screen Shot 2021-11-15 at 4 52 26 PM

@ryelle ryelle force-pushed the update/restricted-media-library branch 2 times, most recently from c2c5137 to ce8984f Compare November 19, 2021 18:21
@ryelle ryelle force-pushed the try/openverse-media-gallery branch from d956c3a to 959cf5b Compare November 19, 2021 18:24
Base automatically changed from update/restricted-media-library to trunk November 19, 2021 20:02
@ryelle ryelle force-pushed the try/openverse-media-gallery branch from 959cf5b to 1f47969 Compare November 19, 2021 20:14
@shaunandrews
Copy link
Collaborator

shaunandrews commented Nov 19, 2021

This is super cool. Here's some designs for how I see this looking:
Pattern Media Openverse Search

Some notable changes:

  • Replaced "Openverse Media" with "Pattern media" (Note the sentence case.)
  • Added a "Powered By Openverse" badge.
  • Search is now centered and the whole layout uses a single column.
  • Added some "suggested keywords" that might help reduce the pressure to come up with a search term.
  • Added a "featured" section for when you haven't searched yet. I imagine this would be a small collection of images/videos/audio that we think would work best in most cases. I realize this might be out of scope.
  • Added a reminder that uploading is disabled.
  • I mimicked the Core media library when selecting multiple items by listing those items in the modal's footer.

@sarayourfriend
Copy link
Contributor

This is so rad!

One piece of early feedback (I hope this is okay!) is that we'd likely want to surface the license requirements for each result as early as possible and the resulting image block would need to include the attribution (preferrably in some way that is obvious that it shouldn't be removed for images where the license requires attribution). I'm not sure how the attribution would be handled for the gallery block but hopefully a designer can help with that.

@ryelle
Copy link
Contributor Author

ryelle commented Nov 19, 2021

@sarayourfriend for the Pattern Directory, we're only allowing CC0 images to be returned, so we shouldn't need to worry about attribution. Though we could probably drop it into the caption, and let pattern authors decide to leave it or remove it…? Not sure about that - right now just the item title is added to the caption. (I also want to figure out a good solution for alt text, both when browsing and when inserting images)

@sarayourfriend
Copy link
Contributor

Oh perfect! I didn't catch that when I scanned the code, but that makes sense 🎉

For the alt text, on Openverse we use the image title.

https://github.com/WordPress/openverse-frontend/blob/51af7b01c7b53afbcccfd4ecbe895ae801b7c5de/src/utils/attribution-html.js#L10

@ryelle
Copy link
Contributor Author

ryelle commented Nov 23, 2021

Latest commits get the styling almost-there:

Screen Shot 2021-11-23 at 14 35 26

Screen Shot 2021-11-23 at 14 35 10

I need to get the loading state centered, but I think that's the only thing remaining.

@shaunandrews I noticed an issue for the focus states on the images- when images are selected, there's no distinction between focused or not, and TBH there's not much distinction between focused/selected on the unselected images:

Screen Shot 2021-11-23 at 12 48 16 PM

In core, there's a checkbox that appears on selected items for a clear distinction between focused/selected, we could do something similar with an icon? Open to any other solution too.
Screen Shot 2021-11-23 at 2 39 25 PM

@ryelle
Copy link
Contributor Author

ryelle commented Nov 24, 2021

I'm running into trouble trying to get the media blocks + openverse media to play together… The media blocks use image IDs to indicate what’s currently selected (for example, a gallery is a list of IDs). If we don’t pass through the OV item’s ID, it doesn’t persist selections - you can select images for a gallery, then open the Media Library again and it won’t know that you already have a gallery. On the other hand, if we do pass the OV item ID, the editor tries to make a request to /media/[id], assuming it’s a core media item. The request fails, since the OV IDs are not integers.

We're already intercepting some media API requests, so possibly I could intercept requests that look like OV IDs and short-circuit the return value, but I'm not sure if there's an easier way :)

Edit: Bypassing the API works to prevent the failed request, but it won't save the selected image ID because the media blocks expect the ID attribute to be a number and it does validation.

@shaunandrews
Copy link
Collaborator

when images are selected, there's no distinction between focused or not, and TBH there's not much distinction between focused/selected on the unselected images

I like using the check icon, along with some borders to help identify the various states:

image

@ryelle
Copy link
Contributor Author

ryelle commented Nov 29, 2021

@shaunandrews thanks for the updated styles, I just pushed that change up to the branch so it looks like this now:

Screen Shot 2021-11-29 at 15 12 12

@shaunandrews
Copy link
Collaborator

Great. Looks like the "Cancel" button at the button is getting cut off somehow.

Will the results always be "10000"? If so, maybe we don't need the number of results. If the number could/does change, can we give it a proper counting treatment? That is, adding comma's/point's where they belong. Like, "10,000" instead?

@ryelle
Copy link
Contributor Author

ryelle commented Nov 29, 2021

Cancel button: I think that's just because I'm downsizing by taking a 1x screenshot - it looks correct in real life:

Screen Shot 2021-11-29 at 4 58 43 PM

Result count: The demo suggestions are all very broad, so they max out at 10,000 - result counts are different for more specific searches. I'll see about formatting the number better.

Screen Shot 2021-11-29 at 4 59 51 PM

@ryelle
Copy link
Contributor Author

ryelle commented Nov 30, 2021

Updated to use pagination for viewing older images — images selected on earlier pages stay selected, and are visible in the footer, so you can move between pages and search results to select anything you want.

Screen Shot 2021-11-30 at 3 18 41 PM

Screen Shot 2021-11-30 at 3 18 53 PM

@ryelle ryelle changed the title Add the Openverse Media Library [proof of concept] Add the Openverse Media Library Nov 30, 2021
@ryelle ryelle force-pushed the try/openverse-media-gallery branch from 985cef0 to 98866dd Compare December 2, 2021 17:08
@ryelle
Copy link
Contributor Author

ryelle commented Dec 2, 2021

I'm going to merge this to get the framework in, and the remaining issues can be done in followup PRs:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Component] Pattern Creator Anything related to the pattern front end editor or preview
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create a library of media and only allow that to be used in patterns
3 participants