diff --git a/app/views/timelines/_gallery_panel.html.erb b/app/views/timelines/_gallery_panel.html.erb
new file mode 100644
index 000000000..aa7ae0a2a
--- /dev/null
+++ b/app/views/timelines/_gallery_panel.html.erb
@@ -0,0 +1,6 @@
+<%# The shared content gallery for a timeline. Used by the editor's Images window (loaded over XHR) and timelines#gallery. %>
+<%# Locals: timeline %>
+<%# The form only matters to the gallery's no-JavaScript upload fallback; timelines#update saves its files. %>
+<%= form_for timeline, url: timeline_path(timeline), method: :patch, html: { multipart: true } do |f| %>
+ <%= render partial: 'content/edit/gallery_panel', locals: { raw_content: timeline, content: timeline, f: f } %>
+<% end %>
diff --git a/app/views/timelines/edit.html.erb b/app/views/timelines/edit.html.erb
index 227906802..238205677 100644
--- a/app/views/timelines/edit.html.erb
+++ b/app/views/timelines/edit.html.erb
@@ -1,4 +1,13 @@
+ <%# Banner, as on other content editors. Narrows with the side panels like the main column does. %>
+ <%# Its button opens the Images window; the banner is re-fetched from timelines#cover when that window closes. %>
+
diff --git a/app/views/timelines/gallery.html.erb b/app/views/timelines/gallery.html.erb
new file mode 100644
index 000000000..3c1043b20
--- /dev/null
+++ b/app/views/timelines/gallery.html.erb
@@ -0,0 +1,24 @@
+<%# Images for a timeline as a page of its own: what the editor's cover slot links to when JavaScript is off. %>
+
+
+ <%= link_to edit_timeline_path(@timeline), class: "inline-flex items-center text-sm text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-100 mb-4" do %>
+ arrow_back
+ Back to <%= @timeline.name.presence || 'Untitled Timeline' %>
+ <% end %>
+
+
+ <%# Banner, as on other content pages: the cover, or the stock timeline image without one. %>
+ <%= render partial: 'content/hero_header', locals: {
+ content: @timeline,
+ serialized_content: nil,
+ icon: Timeline.icon,
+ color: Timeline.color,
+ title: @timeline.name.presence || 'Untitled Timeline'
+ } %>
+
diff --git a/config/routes.rb b/config/routes.rb
index 6db15013f..f184f67df 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -397,6 +397,10 @@
resources :timelines, only: [:index, :show, :new, :update, :edit, :destroy] do
get '/tagged/:slug', action: :index, on: :collection, as: :page_tag
get 'tag_suggestions', to: 'timelines#tag_suggestions', on: :member
+ # The image gallery: a full page without JavaScript, the editor's Images window body over XHR
+ get :gallery, on: :member
+ # The editor's cover slot, re-fetched after the Images window closes
+ get :cover, on: :member
post :toggle_archive, on: :member
post :toggle_favorite, on: :member
end
diff --git a/test/controllers/timeline_images_test.rb b/test/controllers/timeline_images_test.rb
new file mode 100644
index 000000000..7d73351ea
--- /dev/null
+++ b/test/controllers/timeline_images_test.rb
@@ -0,0 +1,139 @@
+require 'test_helper'
+
+# Adding images to a timeline and seeing them where a timeline is shown:
+# the editor's banner and Images window, the no-JavaScript gallery page
+# and upload, and the cover on the timeline page and its link previews.
+class TimelineImagesTest < ActionDispatch::IntegrationTest
+ include Devise::Test::IntegrationHelpers
+
+ XHR = { 'X-Requested-With' => 'XMLHttpRequest' }.freeze
+
+ setup do
+ @owner = users(:one)
+ @stranger = users(:two)
+ @timeline = Timeline.create!(name: 'Red Thread', user: @owner, privacy: 'public')
+ end
+
+ def add_image(privacy: 'public')
+ result = ImageUploadService.upload(user: @owner, content: @timeline,
+ file: fixture_file_upload('gallery_test.png', 'image/png'),
+ privacy: privacy)
+ assert result.success?, result.error
+ result.image
+ end
+
+ test "the editor prompts for a cover image and loads the gallery only when asked" do
+ sign_in @owner
+ get edit_timeline_path(@timeline)
+ assert_response :success
+
+ assert_select "[data-open-gallery][href='#{gallery_timeline_path(@timeline)}']", text: /Add cover image/
+ assert_select "img[alt='Red Thread banner image'][src*='card-headers/timelines']"
+ assert_select "[data-gallery-url='#{gallery_timeline_path(@timeline)}']"
+ assert_select "[data-controller~=gallery]", count: 0
+ end
+
+ test "the editor shows the cover image once there is one" do
+ add_image
+ sign_in @owner
+ get edit_timeline_path(@timeline)
+
+ assert_select "[data-open-gallery]", text: /Edit images/
+ assert_select "img[alt='Red Thread banner image']:not([src*='card-headers'])"
+ end
+
+ test "the Images window gets the timeline's gallery without the page around it" do
+ add_image
+ sign_in @owner
+ get gallery_timeline_path(@timeline), headers: XHR
+
+ assert_response :success
+ assert_no_match(/ { @timeline.image_uploads.count }, 1 do
+ patch timeline_path(@timeline), params: {
+ timeline: { image_uploads_attributes: { '0' => { src: fixture_file_upload('gallery_test.png', 'image/png') } } }
+ }
+ end
+
+ assert_redirected_to gallery_timeline_path(@timeline)
+ assert_operator @owner.reload.upload_bandwidth_kb, :<, bandwidth_before
+ end
+
+ test "the editor's own saves still get JSON back" do
+ sign_in @owner
+ patch timeline_path(@timeline), params: { timeline: { name: 'Renamed' } }, as: :json
+
+ assert_response :success
+ assert_equal 'Renamed', @timeline.reload.name
+ end
+
+ test "people who can't edit the timeline can't reach its gallery or upload to it" do
+ sign_in @stranger
+
+ get gallery_timeline_path(@timeline), headers: XHR
+ assert_redirected_to root_path
+ get cover_timeline_path(@timeline), headers: XHR
+ assert_redirected_to root_path
+
+ assert_no_difference -> { ImageUpload.count } do
+ patch timeline_path(@timeline), params: {
+ timeline: { image_uploads_attributes: { '0' => { src: fixture_file_upload('gallery_test.png', 'image/png') } } }
+ }
+ end
+ end
+
+ test "the timeline page shows the cover and uses it for link previews" do
+ add_image
+ get timeline_path(@timeline)
+
+ assert_response :success
+ assert_select "img[alt='Red Thread banner image']:not([src*='card-headers'])"
+ assert_select "meta[property='og:image']" do |tags|
+ assert tags.none? { |tag| tag['content'].include?('card-headers/') }, 'og:image should be the uploaded cover'
+ end
+ end
+
+ test "without a cover the timeline page shows the stock banner, and visitors don't see private images" do
+ stock_banner = "img[alt='Red Thread banner image'][src*='card-headers/timelines']"
+
+ get timeline_path(@timeline)
+ assert_select stock_banner
+
+ add_image(privacy: 'private')
+ get timeline_path(@timeline)
+ assert_select stock_banner
+
+ sign_in @owner
+ get timeline_path(@timeline)
+ assert_select "img[alt='Red Thread banner image']:not([src*='card-headers'])"
+ end
+end