mobile icon indicating copy to clipboard operation
mobile copied to clipboard

Setting photo name expression doesn't respect photo default path

Open erpas opened this issue 2 years ago • 11 comments

When an expression is set for a layer photo names in project Properties dialog AND a default path is also set for photos, then the latter is not respected by the app, i.e. photos are created in main project folder.

erpas avatar Dec 22 '23 07:12 erpas

just wondering if a bug fix for this issue will be implemented in the latest version of mergin maps, i.e., the version currently in beta stage? Although perhaps this is a bug in the QGIS plugin rather than the mobile app. When the photos are dropped in the main project folder it gets messy fast

rjwillson avatar Apr 23 '24 13:04 rjwillson

There is a current workaround for this issue. If using a photo naming expression in the Project properties, include the relative file path to the desired sub-folder in the photo naming expression. For example, if you wanted to save photos to a 'photos' folder in the project directory, you would use an expression like this:

'photos/'||@mergin_username||'-'||format_date(now(),'yyyy.MM.ddThh-mm-ss') 

However, if this is workaround is used, there must not be any custom path selected in the photo attachment widget settings in the layer properties dialogue or the photo will not be saved correctly. image

raherin avatar May 01 '24 14:05 raherin

thanks very much for that workaround @raherin

it totally worked with the current version of mergin. unfortunately, it didn't work for me with the latest beta as it put the photos back in the main folder. I know it's still in beta but I currently can't take the chance it won't work on release.

thanks again!

rjwillson avatar May 02 '24 01:05 rjwillson

The fix will be incorporated in the release 2024.3.1. We will fix it in a way that photo name format will respect photo default path (appended to the photo default path).

tomasMizera avatar Jul 08 '24 11:07 tomasMizera

thanks very much for that workaround @raherin

it totally worked with the current version of mergin. unfortunately, it didn't work for me with the latest beta as it put the photos back in the main folder. I know it's still in beta but I currently can't take the chance it won't work on release.

thanks again!

I couldn't reproduce the bug; it's working fine on my end. Could you please share a project where it occurs so I can investigate further? (My account is [email protected]).

VitorVieiraZ avatar Jul 09 '24 15:07 VitorVieiraZ

Hi guys, we could not reproduce this one, please reopen if you can

tomasMizera avatar Jul 11 '24 13:07 tomasMizera

this issue definitely persists on my end

I can either have the photo rename or the photo directed to a specific directory. Not both. Just tested again on a project i just shared with Vitor.

the project currently tries to have the photo renamed in the project properties if you try to take photo you will see it will not file it into the photo directory indicated. But as soon as you remove the photo rename expression and take a photo it will direct the photo into the correct directory

rjwillson avatar Jul 11 '24 14:07 rjwillson

Hi @rjwillson, thanks for the comment! We will try it on the shared project.

tomasMizera avatar Jul 12 '24 07:07 tomasMizera

Hi @rjwillson,

Thank you for your feedback on this issue.

To resolve it, set the Store path as field to Relative to Default Path. This adjustment ensures that the combination of Default path + Photo name expression functions correctly, as demonstrated in the image below:

VitorVieiraZ avatar Jul 16 '24 01:07 VitorVieiraZ

Internal comment (cc @VitorVieiraZ ), what should be happening:

Photo name expression Photo path configuration Expected result
no photo name expression relative to project path <project_path>/default_photo_name.jpg
set photo name expression relative to project path <project_path>/photo_name_expression.jpg <-- bug here, it keeps the default photo name 🐛!
no photo name expression relative to default path <project_path>/<default_path>/default_photo_name.jpg
set photo name expression relative to default path <project_path>/<default_path>/photo_name_expression.jpg

Please bear in mind that the photo name expression might include subfolders too (should be attached to the default path when the editor is set as Relative to default path).

tomasMizera avatar Jul 17 '24 12:07 tomasMizera

thanks @VitorVieiraZ

interesting, I used to have my photo widgets all set up that way, i.e., set to "Relative to Default Path" but when it is set up that way then media-sync https://merginmaps.com/docs/dev/media-sync/ will not work properly.

Media sync only only seems to work correctly when the widget is set to "Relative to Project Path". So to use media-sync (which I think is the best thing since sliced bread ;) one has to have the widget set to "Relative to Project Path" Otherwise, media-sync will not populate the attribute table's field with the photo's S3 URL. It does not say this in the media-sync documentation so I it took me quite some time to figure out why it was failing several months ago.

I am now using media sync to move the photos to my S3 storage and then send the link back to the attribute table, so I don't have to worry about storing the photos in the mergin folder anymore. So this is no longer an issue for me but I wanted to help out in the troubleshooting.

Hi @rjwillson,

Thank you for your feedback on this issue.

To resolve it, set the Store path as field to Relative to Default Path. This adjustment ensures that the combination of Default path + Photo name expression functions correctly, as demonstrated in the image below:

rjwillson avatar Jul 19 '24 18:07 rjwillson