Skip to content

Media

Point an image or file field at a column of URLs. The importer downloads each file once, adds it to EmDash's media library and reuses it on later runs. Images inside HTML and Markdown come along too.

When a record holds the address of an image or a file, map it to an image or file field and the importer does the rest: it downloads the file, uploads it through EmDash’s media library, and stores the media item in the entry.

In the wizard’s Map step, map a source key to an image or file field. The value must be one absolute http:// or https:// address, at most 2,048 characters, with no user name or password. Each image or file field holds one item, so map one URL per field. A template can have at most 5 image and file mappings, so a record downloads at most 5 files.

When the feed holds only a file name or a relative path, build the address with an expression:

"fields": {
"photo": {
"type": "image",
"expr": "'https://cdn.example.com/products/' & ImageFile",
"alt": { "from": "ImageAlt" }
},
"manual": { "type": "file", "from": "ManualUrl" }
}

An empty value leaves the field empty. A relative address or a data: URL fails the record with invalid_media_url.

Files are downloaded during a real run, one at a time, as each record is written. They go through EmDash’s own upload, so its file type rules, size limit and media hooks apply, and identical files are stored once.

A dry run downloads nothing. It checks each address and whether the file is already stored, and lists the files a real run would download in the record’s changes. It can’t know in advance whether a download will fail, so a real run can still report media errors the dry run didn’t.

The importer remembers every address it has stored, across all imports on the site. When a later run, or another record, has the same address, it reuses the stored media item without downloading it again. That keeps repeat imports fast.

When the file behind an address can change, tick Download the file again on every run in the field’s settings ("refresh": true in the template). Each run then asks the server whether the file changed, using the ETag and Last-Modified headers it sent last time:

  • unchanged: the stored item stays;
  • changed: the new file is uploaded and the entry points to the new item. The old item stays in the library.

An address is downloaded again at most once per import.

An image field can take Alt text from an Alt text key in the record, or from an Alt text expression. In the template, that is "alt": { "from": "…" } or "alt": { "expr": "…" }.

  • The alt text is stored with the image in the entry, so each entry can describe the same picture its own way.
  • When the upload adds a new item to the library, the alt text also becomes the library’s default for it. An item that was already there keeps its own.
  • Empty alt text writes none, and EmDash falls back to the library’s alt text.
  • Alt text can be at most 1,000 characters; longer text fails the record with alt_too_long.

File fields have no alt text.

The file’s content decides its type, not its extension. A field accepts:

  • what EmDash’s upload accepts by default: PNG, JPEG, GIF, WebP, AVIF and JPEG XL images, video, audio and PDF;
  • for an image field, images only;
  • the field’s own list of accepted types, when it has one.

SVG and HTML are always refused, whatever the server says they are. A refused file fails the record with media_type_not_allowed.

A file can be as large as EmDash’s upload limit, maxUploadSize, 50 MiB by default. On Cloudflare Workers the importer caps it at 5 MiB, because EmDash’s upload holds several copies of the file in memory, which a Worker can’t afford for large images. Raise maxUploadSize in your EmDash config to accept larger files on Node.

Each download gets 10 seconds to start answering and 30 seconds in all. When a batch is running out of time, the importer stops before the next download and the next batch carries on from that record. On Workers a batch downloads about 10 files at most.

Downloads go through the same address checks as URL sources: private and local addresses are refused. They never send a credential.

A media problem fails the record, not the import. The record’s log says why:

Code What happened
invalid_media_url The value is not an absolute http or https address.
media_blocked The address is on a private or local network.
media_fetch_failed The server could not be reached, timed out, redirected too often, or sent an empty file.
media_http_error The server answered with an error status.
media_too_large The file is over the size limit.
media_type_not_allowed The file’s type is not allowed, for EmDash or for this field.
media_upload_failed EmDash refused the upload, for example a media hook said no.

Use Retry failed records on the import’s row in Jobs to try them again. Files that were already stored are reused, not downloaded again.

If the site has no media storage configured, or an invalid maxUploadSize, every upload would fail, so the import stops with media_config.

A Portable Text field mapped from HTML or Markdown imports the images in it too. Each image is downloaded like an image field’s file, stored in the media library, and becomes an image block. Its alt text comes from the image’s own alt text, cut to 1,000 characters.

The field’s settings control them:

  • Images: Import them, or Skip them to leave images out.
  • When an image cannot be imported: Leave it out (the default; the record gets a warning) or Fail the record.
  • Base URL for relative links: the address that relative image paths, such as /img/photo.jpg, are read against. Without it, a relative image can’t be imported.

A record can hold at most 50 different image addresses across its Portable Text fields. The ones past that are left out, or fail the record when it is set to fail.

The importer never deletes media. A file stored for a record that then fails stays in the library and is reused on the next run. A rollback keeps the media an import added, because EmDash can’t tell whether other content uses it, and lists the items so you can delete them yourself.