2

I would like to know how to display a photo in a image viewer with a featured action. I create a layer with 3 fields: id, leyenda and filepath. Filepath is the field where I put my photo..

example1 Then I created an action to open the picture who will be attached example2 But when I use the action (the cursor change) nothing happened.

Do you know why and how to solve the problem ? example3

3
  • As you can see, I can view my picture in the attribute table – A.Badouk 1 hour ago – A.Badouk Jul 15 '20 at 0:26
  • What operating system are you using? The instructions at docs.qgis.org/testing/en/docs/training_manual/… are a bit different for Linux, Windows, and Mac. Beyond that, I'd also check whether filepath is fully qualified, and if (on Windows) there isn't a forwardslash/backslash problem. – Houska Jul 15 '20 at 21:18
  • I'm using windows 10 and i also follow the same instructions – A.Badouk Jul 16 '20 at 10:54
1

After some playing around, here are 2 issues that might be getting in the way.

  1. While display of an image inside QGIS using the form File widget respects relative paths (if Relative Paths is checked), I don't think an Open action does. So there instead of [%filepath%] try [%concat(@project_home || '\\', "filepath" )%]. This will prepend the project home path to the filename to make it fully qualified. (The '\\' becomes the single backslash used in Windows, of course.)

  2. Shouldn't be the case for .jpg, but you need to have a file association in place in the operating system to be able to automatically open the filenames passed to it. It's possible this is somehow broken on your system.

What's unfortunate is that if the OS doesn't know what to do with the (incomplete or unassociated) filename in the action, no error message is generated, just nothing happens. So to debug such problems, I suggest the following.

A. Copy the contents of "filepath" (or whatever) for one feature.

B. Open a terminal window (via the Browser or otherwise) in a random directory.

C. Try to execute as a command that one filename, by typing " then Ctrl-V to paste what you just copied then another ".

If it's all good, it should open the file, both this way as well as in your desired QGIS action. If it's not working, you'll hopefully get a meaningful error message this way why it's failing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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