Skip to content
github-actions[bot] edited this page Dec 4, 2026 · 3 revisions

Media

Images and files belong to a site. Entries use them through medium fields (see Content types), and websites get them from the read API (see Reading content).

Administrators and editors who work on a site upload, change and delete its media, in the administration under the site's Media, through the API or as an AI program (see AI programs).

What can be uploaded

Kind Files
Images JPEG, PNG, GIF, WebP, AVIF, SVG
Documents PDF, text, CSV, Word, Excel and PowerPoint (.docx, .xlsx, .pptx), ZIP
Video and audio MP4, WebM, MP3, WAV

OwnCMS finds the kind of a file in its content, not in its name or in what the uploading program claims. Web pages and programs are never accepted. A file may be up to 50 MB; -max-upload changes the limit (see Reference).

Images get their width and height; for photos turned by the camera, as they are seen. The file name is kept, without folders or characters that don't belong in a name, and gets the extension of its kind if it lacks one.

Alternative text

Every image can have an alternative text per language of the site. It describes what the image shows, for people who cannot see it and for search engines. Websites get it with the image.

Using media in entries

A medium field holds a medium of the same site, or several when it allows more than one. An entry can only be saved with media that exist on its site.

A medium that entries use cannot be deleted, also not by entries in the bin. Deleting it says which entries use it: take it out of them (and publish them) first. A deleted medium is gone for good.

The content of a medium never changes. To replace an image, upload the new one and choose it in the entries.

Where media are kept

The content of media is kept in the data directory under media/ unless another place is chosen; back it up together with the database. Uploads wait in tmp/ while they are checked. Deleting a site deletes its media, wherever they are.

Administrators of all sites can add other places under Storage, signed in with their password (not with an access token, since these settings hold credentials of other systems):

Place What it needs
Object storage, S3-compatible (Amazon S3, Hetzner, Backblaze B2, Cloudflare R2, MinIO, …) the endpoint (https://…; empty for Amazon S3), the region, the bucket, an optional prefix so several programs can share a bucket, the access key and the secret key; "bucket in the path" for MinIO and buckets with dots
A server over SFTP (a NAS, a storage box, any OpenSSH server) the address (host or host:port), the user, a password or a private key (with its passphrase), the server's public key as ssh-keyscan prints it, and the folder

A place is only added or changed when OwnCMS could write, read and delete a test file there; otherwise the reason is shown. Keys and passwords are sealed with the data directory's secret.key and never shown again; to change one, enter the new one, empty fields keep what is saved. Back up secret.key: without it the keys cannot be read and OwnCMS cannot reach the place.

One place is the one new images and files go to. Each medium stays where it was uploaded, so choosing another place moves nothing; media in the old place are still delivered from there. A place can only be removed when it holds no media and new files do not go there. Smaller copies of images (sizes and web formats) are kept next to their original.

Delivered to websites

/content/<site>/media/<id>/<name> delivers a medium. Public sites deliver it to anyone; sites that are not public only with a key. Media are not drafts: once uploaded, a medium of a public site can be fetched by anyone who knows its address, even before an entry that uses it is published.

Answers support ranges (for video), carry an ETag and may be kept by browsers and caches for a year, since a medium's content never changes. Nothing in a medium can run in the browser, not even a script inside an SVG.

Sizes and web formats

Websites can ask for an image in the width and format they need, at the same address:

Parameter Meaning
w the width in pixels: 320, 640, 960, 1280, 1920 or 2560. An image narrower than that is delivered at its own width, never larger
format webp, avif, jpeg or png; auto (also when only w is given) delivers AVIF or WebP when the browser accepts them, else the image's own format
<img src="https://cms.example.com/content/blog/media/06h…/team.jpg?w=960&format=webp"
     srcset="…?w=640&format=webp 640w, …?w=1280&format=webp 1280w" sizes="100vw" alt="…">

Each size and format is made the first time it is asked for (a large photo takes up to about a second, AVIF the longest) and kept for every request after; it goes with the medium. Photos are turned the way the camera says, and the copies carry no camera data or location (the original is delivered as it was uploaded, with whatever data it holds). Images over 50 million pixels are only delivered as they are. Drawings (SVG) and GIFs are always delivered as they are.

In entries

In the JSON of an entry, a medium field holds an object instead of the id:

{"id": "06h…", "url": "https://cms.example.com/content/blog/media/06h…/team.jpg",
 "name": "team.jpg", "type": "image/jpeg", "size": 183204, "width": 1600, "height": 900,
 "alt": "The team in front of the office",
 "srcset": "https://…/team.jpg?w=320&format=webp 320w, …, https://…/team.jpg?w=1920&format=webp 1600w"}

alt is the text in the language asked for with lang (or the default language), and an object of all languages without lang. srcset lists the widths of an image in WebP, ready for <img srcset>. In Markdown, images are images and other files links.

Clone this wiki locally