Directory / plugin
PhotoFetch
v2.0.0 · by Topher
Search the WordPress Photo Directory (wordpress.org/photos) and import CC0 photos straight into your Media Library.
About this plugin
This plugin adds a “Photo Directory” search UI to wp-admin that talks to the
public Photo Directory REST API.
You can search, preview, and import photos directly into your own Media
Library, where the imported image behaves exactly like any regular upload
— usable as a featured image, inside blocks, in a gallery, etc.
Entry points:
- Media > Photo Directory — a dedicated search/browse admin page.
- “Photo Directory” button next to Add Media in the classic editor.
- “Photo Directory” tab inside the native WordPress media picker itself
(Set Featured Image, Add Media, an Image block’s Media Library button,
etc.) — works in both the classic and block editor, since they share the
same underlying media picker.
Notes for developers
- This is an unofficial integration with a public but not formally
documented API.includes/class-photofetch-api.php::normalize_item()is where
the raw JSON from the Photo Directory gets mapped into predictable
sizes/alt/authorfields — it tries several plausible shapes
(media_details.sizes, an embedded featured-media object, a bare
source_url, etc.). If wordpress.org changes the API’s response shape,
this is the one function that should need updating. - Title and alt text are sourced independently: alt text prefers a real
alt-text field if the API exposes one, otherwise falls back to the same
text used for the Description field (seePhotoFetch_API::normalize_item()for
the exact priority order). It’s never derived from the title. For title,
known upstream placeholder strings (currently “Photo Detail”, “Untitled”,
“Untitled Photo” — seephotofetch_generic_title_placeholdersfilter) are
treated as no title at all, and a fallback title is derived from the
photo’s slug instead (e.g.red-fox-in-snow“Red fox in snow”). If
the slug itself isn’t usable, the title falls back to “Untitled photo”. - The attachment’s Description field (post_content) and alt text both get
the photo’s full description text; its Caption field (post_excerpt) gets
only the photographer credit line (e.g. “Photo by Jane Smith, via the
WordPress Photo Directory.”), or is left empty if no author name is
available. - The search/browse picker UI doesn’t display each photo’s title — many
photos on the Photo Directory only have a slug-derived fallback title
(see above), which isn’t meaningful to show while browsing. The title is
still set on the imported attachment; it’s just not shown in the grid. - Imports are deduplicated: each imported attachment gets a
_photofetch_source_id meta value, and re-importing the same photo returns the
existing attachment instead of downloading it again. - Image format conversion (Settings > Photo Directory,
PhotoFetch_Settings::get_format()) happens in
PhotoFetch_Importer::maybe_convert_image(), right after download and before
sideloading. It re-checkswp_image_editor_supports()at import time
rather than trusting the stored setting outright, and falls back to the
original file on any failure. - Search results are cached for 5 minutes via transients to avoid hammering
the upstream API on repeat searches. - All photos on the Photo Directory are released CC0 (no attribution
required), but the plugin stores the original photo URL and author name
(when available) as_photofetch_source_url/_photofetch_source_authorattachment
meta for your own reference, in addition to the caption credit above.