Add Unsplash illustration collection mode (and fix import)#692
Conversation
|
Where can I find the collection ID? I can't seem to find it anywhere on the Unsplash website. All collections appear to be identified by name now |
The collection ID is the part immediately after /collections/ in the URL. For example, in /collections/QZU1xPqbVYM/its-getting-dark, the ID is QZU1xPqbVYM. I’ll update the helper text to make this clearer. |
|
Got it, thanks for the explanation It worked with numeric IDs, for example: But IDs containing underscores, hyphens, or letters failed, for example: https://unsplash.com/pt-br/cole%C3%A7%C3%B5es/2_1SzDWjSSs/travel The example you gave also did not work for me: QZU1xPqbVYM /collections/QZU1xPqbVYM/its-getting-dark The error I get is: Error! An error occurred: Failed to fetch image from Unsplash API, please check logs |
This PR updates the Unsplash plugin so it can load not only regular photos, but also Unsplash
illustrationassets from collections.Previously, the plugin used
/photos/randomwhen no search query was provided. That works for photo collections, but Unsplash does not returnasset_type: illustrationitems through that endpoint. Collections that contain only illustrations therefore failed withNo photos found, even though/collections/{id}/photosreturned valid items.The plugin now supports an explicit content type setting:
Photoskeeps the existing behavior.Illustrations from collectionsloads onlyasset_type: illustrationitems.Photos and illustrations from collectionsloads both photos and illustrations.Key Changes
asset_typehandling insrc/plugins/unsplash/unsplash.py./search/photoswhensearch_queryis set./photos/randomotherwise.illustrationandmixedmodes using:/collections/{collection_id}/photosasset_type.regularon low-resource devices,fullotherwise)regularsmallfullrawillustrationormixedwithout collections.illustrationormixedwithsearch_query.src/plugins/unsplash/settings.htmlwith a newContent Typeselect.tests/test_unsplash_plugin.pycovering the new behavior.Behavior Notes
/illustrations/randomendpoint./search/photos.illustrationandmixedmodes,orientationis passed through, butcoloris not sent because the collection photos endpoint does not document acolorparameter.urls.regular,urls.full, etc., and the existing image loader already downloads and converts them through Pillow.Testing
Ran:
Result:
Covered scenarios:
search_query.