Skip to content

upload

Renders a file upload input with built-in handling for images, video, audio, and documents within a submission form.

Usage

liquid
{% upload id: 'field_id', type: 'image', class: 'btn btn-primary' %}
  <span class="upload">Upload</span>
  <span class="uploading">Uploading...</span>
  <span class="uploaded">Uploaded</span>
{% endupload %}

The inner content is rendered inside a <label>. The .upload, .uploading, and .uploaded spans are not required, but are a standard pattern — bundled CSS uses these classes to reflect upload state automatically.

Options

OptionTypeDefaultDescription
typestringimageFile type — image, video, audio, or document
idstringID applied to the file input and its label
classstringCSS classes on the wrapper <div>
acceptstring(see below)Override the accepted MIME types
multiplebooleanfalseAllow multiple files — typically used with type: 'image' only
requiredbooleanfalseSee note on validation below
thumbstringDimensions for a thumbnail to generate on upload, e.g. 400x400

File types

Default accepted MIME types and size limits by type:

TypeAcceptMax size
imageimage/jpeg, image/png, image/gif10MB
videovideo/*50MB
audioaudio/*10MB
documentapplication/pdf, application/msword4MB

Use the accept option to override the default for any type, e.g. accept: 'audio/mp3' or accept: 'application/pdf'.

Examples

Image upload:

liquid
{% upload id: 'image_profile', type: 'image', class: 'btn btn-primary d-block' %}
  <span class="upload">Upload</span>
  <span class="uploading">Uploading...</span>
  <span class="uploaded">Uploaded</span>
{% endupload %}

Multiple image upload:

liquid
{% upload id: 'gallery_images', type: 'image', class: 'btn btn-primary d-block', multiple %}
  <span class="upload">Upload</span>
  <span class="uploading">Uploading...</span>
  <span class="uploaded">Uploaded</span>
{% endupload %}

Video upload:

liquid
{% upload id: 'video_demo_reel', type: 'video', class: 'btn btn-primary d-block' %}
  <span class="upload">Upload</span>
  <span class="uploading">Uploading...</span>
  <span class="uploaded">Uploaded</span>
{% endupload %}

Audio upload with restricted MIME type:

liquid
{% upload id: 'audio_sample', type: 'audio', class: 'btn btn-primary d-block', accept: 'audio/mp3' %}
  <span class="upload">Upload</span>
  <span class="uploading">Uploading...</span>
  <span class="uploaded">Uploaded</span>
{% endupload %}

PDF document upload:

liquid
{% upload id: 'resume_pdf', type: 'document', class: 'btn btn-primary d-block', accept: 'application/pdf' %}
  <span class="upload">Upload</span>
  <span class="uploading">Uploading...</span>
  <span class="uploaded">Uploaded</span>
{% endupload %}

Events

Events are fired on the rendered wrapper <div class="syngency-uploader"> element.

EventDescription
uploadStartedFired when the file begins uploading to S3. The wrapper data-status is set to uploading.
uploadSuccessFired when the upload completes successfully. The wrapper data-status is set to uploaded. Passes an object with key (the S3 object key) and thumbUrl (the generated thumbnail URL, if thumb was set).
uploadErrorFired if the upload fails. The wrapper data-status is set to error.

Example:

js
$('.syngency-uploader').on('uploadSuccess', function (e, data) {
  console.log(data.key);      // S3 object key
  console.log(data.thumbUrl); // Thumbnail URL (if thumb option set)
});

Notes

  • Validation: the required attribute is unreliable for upload fields since the underlying file input is never populated by the browser. The recommended approach is to validate using .required[data-status] — the wrapper element receives data-status="uploaded" once a file has been successfully uploaded, which can be checked before form submission. This is handled automatically when using Syngency themes.
  • Previously uploaded values: if a value is present in GET or POST for the field id, the wrapper will render with data-status="uploaded" and a hidden input will be included to retain the value on submission.
  • Allowed characters: option values are restricted to a-z A-Z 0-9 - _ / * space.