openverse-api
openverse-api copied to clipboard
Use `thumbnail_url` for thumbnail generation when present
Problem
Some providers (like SMK) may link to quite large images in their image_url. This can cause unacceptably slow response times or even timeouts when generating thumbnails via our thumbnail service.
Description
We already have a thumbnail_url available on the Image model which we can use.
When the thumbnail_url is available, we should send this to the thumbnail service instead of the image_url. This should be a small change here:
image_url = image.thumbnail or image.url
(using the serialized field names)
Additional context
https://github.com/WordPress/openverse-catalog/issues/698 tracks updating the SMK provider script in the Catalog to populate thumbnail_url with a link to a smaller image size.
Implementation
- [ ] 🙋 I would be interested in implementing this feature.
Just a heads-up, the field name in the API right now is just thumbnail not thumbnail_url: https://github.com/WordPress/openverse-api/blob/2e85caf7aede8aaf9d77cd5cb050f50b860ee58e/api/catalog/api/models/mixins.py#L92