I have a layer "transects" where a photo is taken within the attribute form for a point. Before taking the photo, the person in the field must input the date, creek name, site ID, and transect number.

I would like the corresponding picture to save like "DCIM/transects-creekname_YYYYMMDD_siteID_transectnumber.jpg" For example, "DCIM/transects-Frazer_20230705_QUN13_1.jpg"

Is there a way to format this in QField so that it extracts and names the photo with inputs from the point that has the photo? When in the layer properties>attributes form>widget, do the "default path", "storage mode" need to be something specific?

As of now, my widget display looks like this:

enter image description here

1 Answer 1


Yes. But, I cannot see the attributes "creek name" or "siteID". I have assumed "creek name" is an alias for "stream_name" and "siteID" is an alias for "reachID ".

In properties of the layer 'Transect Measurements', click onto the QField Tab. There you will see an expression editor for Attachment naming, as shown in the image below. enter image description here

Click the expression editor. Try the following code.

'DCIM/transects-'||"stream_name"||format_date(Now(), 'yyyyMMdd')||'_'||"reachID"||'_'||"transect_num"||'.jpg'

However, if any of "stream_name", "reachID" or "transect_num" are null, then the above expression will fail, and QField's default photo naming will be used. You might therefore want to add coalesce() expressions around each of these to provide a substitute for null values.

You are also allowing only one photo per record. Is this deliberate? You can allow multiple photos. To do this you create a table (no geometry) called 'photos' with fields "fid", "tm_fid" (foreign key), "path" and if you want "text" so users can add comments to the photo. Then create a relation with "photos" as the referencing layer, "transects measurements" as the referenced layer, joining on "photos"."tm_fid" = "transects measurements"."fid". Configure form of "photos" so that "path" is an attachment widget, then add the relation to your "transects measurements" form. If doing this I recommend adding a timestamp at the end of the date stamp to avoid duplicate photo names, i.e. format_date(Now(), 'yyyyMMdd_hhmmss'.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.