Skip to main content

Overview

Markdown-OS provides seamless image handling with drag-and-drop upload, clipboard paste, and automatic storage in a dedicated images/ directory.

Uploading Images

Drag and Drop

Drag image files directly onto the editor:
1

Drag an image file

Drag a .png, .jpg, .jpeg, .gif, .webp, .svg, .bmp, or .ico file from your file manager onto the editor area.
2

Drop to upload

The editor shows a visual drop target. Release the mouse to upload.
3

Image is inserted

The image is uploaded to /api/images, saved to the images/ directory, and inserted at the cursor:

Paste from Clipboard

Copy an image and paste it directly into the editor:
1

Copy image

Copy an image from any source:
  • Screenshot tools (Cmd+Shift+4 on Mac, Win+Shift+S on Windows)
  • Browser right-click → Copy Image
  • Image editing apps
2

Paste into editor

Click in the editor and press Cmd/Ctrl + V
3

Image is inserted

The image data is uploaded and a markdown reference is inserted at the cursor position.
Pasting images works with screenshots, copied browser images, and files from your clipboard. The image format is auto-detected.

Insert Menu Button

Use the toolbar to insert images by URL:
  1. Click the Insert menu in the toolbar
  2. Select Image
  3. Enter the image URL when prompted
  4. Optionally enter alt text
  5. The markdown reference is inserted:
This method is useful for embedding external images without uploading.

Upload API

Endpoint

Response

The path field is the relative path used in markdown. The filename is the sanitized name with timestamp.

Implementation

The upload handler validates and processes images:

Storage Location

Single File Mode

Images are stored in an images/ directory adjacent to your markdown file:

Directory Mode

Images are stored in an images/ directory at the workspace root:
All markdown files reference images using the same relative path:
The images/ directory is created automatically on first upload. You don’t need to create it manually.

Filename Sanitization

Filenames are sanitized to ensure filesystem compatibility:
Examples: Timestamps prevent filename collisions when uploading multiple images with the same name.

Supported Formats

Markdown-OS accepts these image formats:
Attempting to upload other file types (e.g., .pdf, .txt, .mp4) results in a 400 error:
SVG files are allowed but rendered as-is without sanitization. Only upload SVGs from trusted sources to avoid XSS vulnerabilities.

Size Limits

Maximum upload size is 10 MB:
Larger files are rejected:
For very large images, consider:
  • Compressing before upload using tools like ImageOptim, TinyPNG, or imagemagick
  • Using external image hosting (Imgur, Cloudinary) and linking by URL
  • Storing images in Git LFS for version control

Serving Images

Uploaded images are served via the /images/{filename} endpoint:
Security:
  • Path traversal attempts (../, absolute paths) are blocked
  • Only files within the images/ directory are accessible
  • Non-existent files return 404

Markdown Embedding

Images are embedded using standard markdown syntax:

With Size Attributes (HTML)

For precise sizing, use HTML <img> tags:

Responsive Images

Images scale responsively in the editor using CSS:

Alignment

Use HTML and inline styles for alignment:

Image Management

Listing Images

Images are just files in the images/ directory. List them with:

Deleting Images

Delete unused images manually:
Markdown-OS doesn’t track image usage. Deleting an image that’s still referenced in markdown will result in a broken image link.

Finding Unused Images

Find images not referenced in any markdown file:

Organizing Images

While Markdown-OS stores all images flat in images/, you can organize them with subdirectories:
Reference with subdirectory paths:
However, uploads always go to the root images/ directory. Manual organization is required.

External Images

You can also reference external images by URL:
External images:
  • Don’t count toward the 10 MB upload limit
  • Load from the external server (requires internet)
  • May break if the external URL changes
  • Work without uploading to your workspace
For documentation that might be viewed offline, upload images rather than linking externally.

Common Issues

Images Not Displaying

Cause: Incorrect relative path
Solution: Images must be in the images/ directory. Check the path:

Upload Fails Silently

Cause: Network error or server timeout
Solution: Check browser console for errors:
Common HTTP status codes:
  • 400 - Invalid format or empty file
  • 413 - File too large (>10 MB)
  • 500 - Server error (check server logs)

Drag-and-Drop Not Working

Cause: Browser security restrictions or JavaScript disabled
Solution:
  • Ensure JavaScript is enabled
  • Try paste instead of drag-and-drop
  • Check for browser extensions blocking events

Images Render Broken After Move

Cause: Image file was moved or deleted
Solution: Re-upload the image or update the markdown reference to the new path.

Performance Tips

Optimize Before Upload

Reduce file sizes before uploading:

Lazy Loading

The editor uses native lazy loading for images:
Images below the fold load only when scrolled into view.

Responsive Images

For high-DPI displays, use srcset:
Upload both logo.png (standard) and logo@2x.png (retina) versions.