Under https://wordpress.org/photos/ more and more photos that you can use in your own projects without worrying about licenses. With the „External files for the media library“ plugin, you can also import these into your own project. The way to do this is described below.
Introduction
The project under https://wordpress.org/photos/ does not offer its own API for importing images. But it is a WordPress with a publicly accessible REST API. And you can use this to find all the images that are stored there.
You could now call up the entire directory, but this would a) be confusing and b) take ages to load the directory completely. My recommendation would be to consider in advance what specific photos you need from the directory.
Search for keywords
You can have the REST API search for keywords in the files. The return would then only contain matching files. An example would be a search for files with the keyword „Germany“:
https://wordpress.org/photos/wp-json/wp/v2/media?search=germanyThis would allow you to list many files and import them.
Search for specific files
You can also search in advance for a file that you want to import individually. To do this, call up its detail page and look at the URL. Example:
https://wordpress.org/photos/photo/6906906198/The numbers at the end 6906906198 are the identifier of the image. You can now search for it:
https://wordpress.org/photos/wp-json/wp/v2/media?search=6906906198 Retrieve REST API
To import the desired files into your media library, proceed as follows:
- In your WordPress backend, go to Media library > Add external files > WordPress REST API.
- Enter the URL you determined as described above in the input field and submit the form.
- Wait a moment until the data is loaded.
- The files will then be displayed and you can import them by clicking on them.
Leave a Reply