Making WordPress.org

Opened 7 months ago

Closed 7 months ago

Last modified 7 months ago

#7280 closed feature request (fixed)

Add CORS headers to the image download URL responses

Reported by: olgabulat's profile olgabulat Owned by:
Milestone: Priority: normal
Component: Photo Directory Keywords:
Cc:

Description

In order to improve Photo Directory integration in Gutenberg through Openverse, the direct image URLs needs to set Access-Control-Allow-Origin="*" headers.

Gutenberg Openverse media inserter tries to download the images from providers (such as Photo Directory) and add it to the Media Library. When the direct image URL does not have a CORS header, the following error is thrown:

This image cannot be uploaded to your Media Library, but it can still be inserted as an external image.

This is the code in Gutenberg that shows this modal when an image cannot be fetched due to CORS issue:

https://github.com/WordPress/gutenberg/blob/6db51a6ee92db6c3324a875135656861bbd9e55d/packages/block-editor/src/components/inserter/media-tab/media-preview.js#L145-L149

Can we add the CORS headers to the image URLs?

Attachments (1)

CleanShot 2023-09-15 at 12.56.25@2x.png (136.5 KB) - added by olgabulat 7 months ago.
Error when adding an image from Photo Directory using Gutenberg Openverse integration

Download all attachments as: .zip

Change History (4)

@olgabulat
7 months ago

Error when adding an image from Photo Directory using Gutenberg Openverse integration

This ticket was mentioned in Slack in #meta by courtneyengle. View the logs.


7 months ago

#2 @coffee2code
7 months ago

  • Resolution set to fixed
  • Status changed from new to closed

@olgabulat: Thanks for the report! I've added the Access-Control-Allow-Origin="*" header to the direct image URLs.

I've verified the header and tested it on a WP 6.3 install by searching Openverse via the Media Inserter to find an image that originated in the Photo Directory. It worked. (I, however, neglected to confirm that it didn't work before the change.) Let me know if the change is insufficient and what else may be needed.

#3 @olgabulat
7 months ago

Thank you so much, @coffee2code! I tested on the Openverse make blog, and the images are uploaded correctly.

Note: See TracTickets for help on using tickets.