Toloka documentation

Button for image file upload

    Note

    The task interface configuration guide describes the features of the HTML/JS/CSS editor. You can also try creating a button for uploading images in Template Builder.

    To add an image upload button to the task, use the {{field type= "file-img" name="<output field name> "sources="<sources parameter>" fileType="<fileType parameter>"}}. After the image is uploaded the Toloker will see an icon for image preview. Example:

    {{field type="file-img" name="photo" sources="CAMERA" fileType="IMAGE" camera=true}}
    

    In the output data description, add one of the fields:

    • Field with the file type — for uploading one image only. Example:

      {
      "result": {
      "type": "file",
      "required": true
      }
      }
      
    • Field with the array_file type — for uploading several images at once. Example:

      {
      "result": {
      "type": "array_file",
      "required": true
      }
      }
      

    Parameters

    Parameter

    Description

    Required

    Default value

    type

    Field type: file-img — Button for image file upload.

    yes

    no

    name

    Attribute for the output data field. Contains the output field name.

    yes

    no

    sources

    Note

    This parameter applies to the tasks completed in the mobile app.

    The file source.

    You can specify multiple values in the sources="<value 1> <value 2>" (with a space, without a comma).

    Supported values:

    • CAMERA.

    • GALLERY.

    • FILE_MANAGER.

    Yes (when creating tasks for mobile devices)

    no

    fileType

    Note

    This parameter applies to the tasks completed in the mobile app.

    File type: IMAGE.

    Yes (when creating tasks for mobile devices)

    no

    validation-show

    The position of popup hints (displayed if the response didn't pass validation). The position is relative to the input field.

    Supported values:

    • Above the input field: "top-left", "top-center", "top-right".

    • Below the input field: "bottom-left", "bottom-center", "bottom-right".

    • To the left of the input field: "left-top", "left-center", "left-bottom".

    • To the right of the input field: "right-top", "right-center", "right-bottom".

    • Don't display the message ("false").

    no

    "top-left"

    preview

    Displaying an image preview after image file upload:

    • preview=true — Display an image preview.

    • preview=false — Don't display an image preview.

    no

    true

    camera

    Open the camera when the image upload button is clicked:

    • camera=true — Open camera.

    • camera=false — Don't open camera.

    no

    false

    compress

    Image compression:

    • compress=true — Reduce the shorter side to 1000 pixels. The image is saved in the JPEG format with a quality level of 90.

    • compress=false — Leave image without changes.

    no

    true

    requiredCoordinates

    Whether coordinates should be required in the image data.

    • requiredCoordinates=true — Coordinates should be required.

    • requiredCoordinates=false — Coordinates should not be required.

    no

    false

    multipleSelect

    The number of files to download at the same time.

    For the single file upload, set the value to false.

    For upload of multiple files:

    1. Set the value to true.

    2. In the output data description, add a field with the array_file type or another type of array.

    no

    true (if the output data description contains a field with the array_file type or another type of array).