WordPress / openverse

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
https://openverse.org
MIT License
254 stars 204 forks source link

Add thumbnails to Wikimedia #3075

Open krysal opened 1 year ago

krysal commented 1 year ago

Problem

Related to #2442, we have seen tiff images coming from Wikimedia, so while that issue gets solved, we can also add thumbnails to these images and prevent situations where the browser can't show the image, like the following case:

https://openverse.org/image/3caf9d55-f9b3-471b-9ce2-926fdb07a0e4

Screenshot 2023-09-27 at 14-24-39 File France Rouen 16th century - Leaf from a Book of Hours- Adam and Eve and the Fall of Man (Prefatory Mini - 2001 79 a - Cleveland Museum of Art tif Openverse

Description

We can get the thumbnail of the width we want appending the param iiurlwidth=<desired_number> to the API endpoint, e.g: https://commons.wikimedia.org/w/api.php?action=query&titles=File:Albert%20Einstein%20Head.jpg&prop=imageinfo&iiprop=url|user|dimensions|extmetadata|mediatype|size&iiurlwidth=600

One possible issue with this is that the documentation says:

For performance reasons if this option is used, no more than 50 scaled images will be returned.

Our current batch limit is set to 250.

Additional context

Source: https://wmds-archive.toolforge.org/t/accessing-a-commons-thumbnail-via-wikidata/499/

HarrySidhuz0008 commented 1 year ago

Upload an Image: First, upload your image to Wikimedia Commons.

Edit a Page: Go to the Wikimedia page where you want to add the thumbnail.

Add Image Link: Use double square brackets and the "File:" prefix to link to your image, like this: [[File:YourImageFilename.jpg]].

Customize Thumbnail: If needed, adjust the thumbnail's size, position, and caption within the brackets, like this: [[File:YourImageFilename.jpg|thumb|right|250px|Caption for the image]].

Save the Page: Save the page to display your thumbnail.

sarayourfriend commented 2 months ago

We've started generating thumbnail URLs on the fly for Wikimedia in #4736. Do we still need proper thumbnail URLs in the catalogue for Wikimedia? One of the difficulties is that the Wikimedia thumbnail endpoint also supports compression and resizing. Building them in the API means we have finer grained control over where we send parameters for those things, which also improves our ability to serve thumbnails for TIFFs and other formats Photon does not support. Using static thumbnail URLs in the catalogue would limit our ability to take advantage of that.

Can we close this issue in favour of the solution in #4736 or do y'all feel that is only a stop-gap, and a catalogue based approach would be better suited?

AetherUnbound commented 2 months ago

I have seen this and will respond to this discussion when I have time!

sarayourfriend commented 2 months ago

Sounds good. I was mostly expecting @krysal to reply as the author of the issue, just to clarify.