Saltar a contenido

Use Attachment

In QField, fields configured with the Attachment widget can:

  • Display and capture photos.
  • Display and record video clips.
  • Listen to and record audio clips.
  • Display links to external files like PDFs or documents.

Default option: Photo
Default option: Photo

Widget configuration

In order for the attachments to be saved appropriately, it is necessary to keep a few things in mind.

  • Widget Type: The widget type needs to be set to Attachment
  • Project Path: The path needs to be set to relative. The pictures, sound clips, videos, PDF's and documents are stored then in a sub-directory of the project, where the link stored in the text field is pointing to.
  • Synchronization Settings: Attachments are generally stored in sub-directories of the project folder. In the QField Settings of the project, these sub-directories also need to be copied. The option hyperlink on the attachment widget will disable that functionality and show just the path to the file hyperlink to open the externally.
  • Depending on what you have selected as default, one of them will be shown inside the form.
  • By default when adding documents as attachments QField automatically displays the file name.
    Media
    Media

Default Attachment name

As stated above, inside the attachment field, the actual attachment path is saved. By default it will point to the project-specific DCIM/Video/Audio folders depending on the media type.

Flujo

  1. Direct to the Properties > QField > Attachments Settings
  2. Use specific expressions to set the required names of the attachments.

Paths
Paths

Añadir una serie de imágenes a un objeto

It is also possible to add more pictures to the feature either by having several attachment field attributes or by creating a relation to a separate table where the image paths are shown. In this section we will show you an example how this is done.

Setting up a relation

A relation to a second layer needs to be set in the QGIS properties so that when adding images or other formats, these are stored in the related table.

Ejemplo

You need two tables containing similar attributes as below.

Parent:

Field Type
id Text (UUID)
geometry Geometry
...

Parent_pictures:

Field Type
id Text (UUID)
parent_id Text (UUID)
path Text
...

Flujo

  1. Create two database tables in your data source using the schema structure below:

  2. Direct to Project Properties > Relations

  3. Click on the
  4. Create a relation with:
    • Referenced layer: Parent
    • Referenced field: id
    • Referencing layer: Parent_pictures
    • Referencing field: Parent_id
    • Composition: strength
      Example relation with "Apiary"
      Example relation with "Apiary"

Configuración del formulario de atributo

Project Manager

Configure attribute forms in feature layers after creating the layer relation. Specify a default value in the apiary parent layer to generate unique primary keys. Set the widget type to Attachment in the apiary_picture child layer.

Workflow

Parent layer configuration:

  1. Direct to Layer Properties > Attribute Form
  2. For the uuid field either choose the Text Edit or the UUID Generator* widget.
  3. Set the default value to uuid('WithoutBraces').
  4. Hide it from the view as it should not be edited by the user.
    widgets
    widgets
  5. Under the Relations* section of your attribute form, the relation to the layer with the photos should be visible. Set the relation widget to many to one relation** and add the relation to the form layout

widgets
widgets

Workflow

Child layer configuration:

  1. Direct to Properties > Attribute Form
  2. Set the widget type to Attachment on the field that will save the picture paths.
  3. Add it to the form layout.
  4. Click Apply
    widgets
    widgets

Drawing Templates

QField includes built-in drawing and sketching tools to annotate captured images, draw on blank canvases, or sketch over templates.

Plantillas de dibujo

Además de anotar imágenes capturadas, QField permite dibujar a partir de plantillas de imágenes. Hay dos métodos disponibles para añadir plantillas:

  • Drawing Templates Folder on Desktop: You can create a folder (drawing_templates) within your project folder and populate it with images. Cada vez que se cargue ese proyecto, QField registrará todas las imágenes de esa carpeta como plantillas de dibujo.
  • Drawing Templates folder on mobile: On your mobile device within your QField directory you will find a folder named drawing_templates. You can copy images directly into this folder and they will act as templates in all projects.

Estampado de imágenes

You can add image stamps to your pictures. This includes, for instance, the date, the location, the title or other desired information.

Flujo

  1. Navigate to the Project > Properties > QField 2 Switch to the third tab at the top of the window Attachments and Directories
  2. Click on Settings next to Customize image stamping details.

You can add the following options:

  • Fuente y Alineación: Tienes control total sobre la apariencia del texto estampado, incluido el estilo de fuente (color, tamaño, sombra) y la alineación horizontal (izquierda, centro o derecha).

  • Decoración de imagen: agregue una superposición de imagen personalizada, como un logotipo o una marca de agua, sobre la imagen capturada.

  • Forzar estampado: esta opción impone el estampado de imágenes, garantizando que todas las imágenes recopiladas para el proyecto tengan la información requerida superpuesta, independientemente de las configuraciones individuales de la aplicación QField.

  • Detalles del sello: crea una cadena de varias líneas utilizando expresiones QGIS para definir la información estampada en la imagen. Se proporciona una plantilla predeterminada para comenzar, que incluye variables comunes como fecha, hora e información GNSS.

Ejemplo

Default Template:

[% format_date(now(), 'yyyy-MM-dd @ HH:mm') %]
Latitude [% coalesce(format_number(y(@gnss_coordinate), 7), 'N/A') %] | Longitude [% coalesce(format_number(x(@gnss_coordinate), 7), 'N/A') %] | Altitude [% coalesce(format_number(z(@gnss_coordinate), 3) || ' m', 'N/A') %]
Speed [% if(@gnss_ground_speed != 'nan', format_number(@gnss_ground_speed, 3) || ' m/s', 'N/A') %] | Orientation [% if(@gnss_orientation != 'nan', format_number(@gnss_orientation, 1) || ' °', 'N/A') %]

Obtención de geoetiquetas (EXIF) del archivo de imagen en la tabla de atributos

Store EXIF geotag parameters (such as latitude, longitude, and camera orientation) directly inside vector attribute fields.

Flujo

  1. Add an attribute per EXIF tag in the table that contains the pictures.
  2. Direct to Layer Properties > Attribute Form
  3. Find the field corresponding to your attachment
  4. Add the desired QGIS EXIF function, and enable the Apply on update.
  5. The EXIF tags that QField can capture are listed in the QGIS documentation (link above). Note: This list might slightly vary depending on the mobile characteristics.
  6. Capturing EXIF tags requires accessing the full physical path of the picture. Be sure to reflect this in the QGIS expression. For example, the expression exif(@project_folder + '/' + "path", 'Exif.Image.Orientation') retrieves the orientation of the picture stored in path. For more tags visit the QField EXIF reference documentation and the exiv library documentation.
  7. Completed! QField now captures and stores the EXIF tags in the pictures table while taking pictures.

Tamaño máximo de la imagen

You can set the maximum picture size to save space.

Flujo

  1. Project > Properties > QField
  2. Change to the third tab at the top of the window Attachments and Directories
  3. Set the maximum size

Attachment and Data Directories

If you have additional folders within your project folder that should be uploaded to QFieldCloud, you have to add them accordingly. All paths are relative to the project directory.

Flujo

  1. Project > Properties > QField
  2. Change to the third tab at the top of the window Attachments and Directories
  3. Choose between Attachments or Data
    Attachments directories
    Attachments directories