A photo page is the gallery’s own post with a photo endpoint added, for example /2011/02/02/photos-grounds/photo/367/, where 367 is the attachment ID. It runs on the post’s own query, so it has the post’s visibility: private and password-protected posts stay protected, and a password-protected post sends visitors to the post to enter the password first.
Which photos belong to which gallery is read from the post’s own blocks, in the order visitors see them, following synced patterns. Only images set to link to the media file or attachment page get a photo page. The list is cached in post meta and rebuilt when the post, or a synced pattern it uses, changes. If the same image is in two galleries on a post, the first gallery is used.
An ID that is not in a gallery on the post is not a photo page. WordPress’s own 404 handling then sends the visitor on to the post itself, so a photo later removed from a gallery still lands somewhere useful, and each post still has exactly one URL per photo.
When a core Gallery block renders, each linked image’s link is pointed at its photo page. This works on the rendered markup, so galleries saved in the current format and the pre-5.9 format are both handled. Images in galleries outside the post content, such as in a template part, keep their original links.
Arrow keys and horizontal swipes follow the same Previous and Next links. Without JavaScript the links still work.
Each photo page is plain HTML that the page cache can serve. The next photo’s image is preloaded, and speculation rules prerender the next page and prefetch the previous one, so in Chromium browsers moving on is close to instant. Browsers that support cross-document view transitions cross-fade between photos, unless the visitor prefers reduced motion.
lh_seo_meta_tags_is_page_meta_owned_elsewhere filter, so the post’s own tags are not printed as well. When Jetpack prints Open Graph tags, its tags are changed instead.wp_robots filter, so there is one robots tag.