Skip to content

Upload step pictures from the web UI #562

Closed

Description

@LeMyst

Summary

#533 (closing #520) let the web editor upload, replace and remove a recipe's title picture (Recipe.jpg). Step pictures were left out of scope. You can still only add them by putting a Recipe.N.jpg / Recipe.S.N.jpg file in the recipe folder yourself. The web server already shows these files, but it can't create them.

That leaves the same gap as #520: someone running cook server on another machine has no way to attach a photo to a step without a separate file manager.

What already exists

  • Display: src/web/builders.rs resolves a step's picture through cooklang-find's step_images(). It supports both naming conventions from image title scheme discrepancy between cli server and ios app #374. It looks for Recipe.S.N.ext first (section S, step N within that section, as the iOS app writes it). If that isn't there, it falls back to Recipe.N.ext (step N counted across all sections).
  • Upload pipeline: src/server/title_image.rs accepts JPEG/PNG/WebP up to 10 MB. It turns the picture upright from its Exif orientation, scales it to at most 2048 px, drops the Exif data and saves a re-encoded JPEG. It refuses HEIC/AVIF with a helpful 415. The editor already shrinks photos before sending them. All of this can be reused unchanged for step pictures.
  • Route: /api/recipe_image/{*path} (GET/PUT/DELETE) with its own 10 MB body limit. PUT deliberately leaves step pictures alone.

Proposal

API

Extend the existing route with query parameters instead of adding a new path segment. The catch-all has to stay last, so a path segment would clash with a recipe folder of the same name (see #533):

GET    /api/recipe_image/{*path}?section=S&step=N
PUT    /api/recipe_image/{*path}?section=S&step=N   (body = raw bytes, as today)
DELETE /api/recipe_image/{*path}?section=S&step=N
  • Without step, the route keeps its current behaviour (title picture).
  • step is 1-based within its section. section is 1-based and defaults to 1.
  • Return 400 when the step or section doesn't exist in the parsed recipe.
  • GET without step could also list every step picture, so the UI can draw its state in one request.

File naming

  • Save as Recipe.S.N.jpg, the name the display code looks for first and the one the iOS app uses. The other option is to save Recipe.N.jpg when the recipe has a single section, which matches the plain spec convention. That choice is up to the maintainers (see the open questions below).
  • On replace or delete, remove that step's older files in both conventions and in every extension (.jpg/.jpeg/.png/.webp). Otherwise an old Recipe.N.png can come back when the new file is deleted, or be picked instead of the new one.
  • Always save .jpg, for the same reasons as the title picture (cooklang-find checks it first, and cook.md sync carries it).
  • Never touch the title picture or other steps' pictures.

UI

Some ways to expose it:

  1. Add a step picker to the editor's existing Picture dialog (Title / Section › Step), reusing its preview, drop zone, replace and remove flow.
  2. Add a small camera button on each step of the recipe page that opens the same dialog, already set to that step.

Option 1 is the smallest change. Option 2 is easier to find, since you see the step you're adding the picture to.

Open questions / known limitations

  • Step numbers shift when steps are edited. Pictures are tied to a position, not to the step's content. Inserting or removing a step earlier in a section moves every later picture onto the wrong step. That's already true for pictures added by hand. Should the editor warn about it, or offer to rename the files when the step count changes? That could reasonably be a follow-up.
  • Should uploads always use Recipe.S.N.jpg, or Recipe.N.jpg for recipes with a single section?
  • Support multiple step-specific images in recipes #173 (multiple pictures per step) is a separate request. This issue is about one picture per step.

Acceptance criteria

  • A step picture can be uploaded, replaced and removed from the web UI, and the recipe page (and cooking mode) show it.
  • It goes through the same processing as title pictures: size limit, Exif orientation, re-encoding, HEIC message.
  • Older files for the same step, in either convention and any extension, are cleaned up. The title picture and other steps are untouched.
  • Integration tests in the style of tests/recipe_image_api_test.rs (spawned through common::with_isolated_config) and a Playwright test for the UI flow.
  • docs/api.md, api_docs.rs and docs/server.md updated. New strings translated for every locale.

Activity

  1. added a commit that references this issue on Sep 30, 2026
    8fb19be
  2. added a commit that references this issue on Sep 30, 2026
    745b349
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions