Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Custom action to link to photos within a GIS feature class.

QGIS Open Image Custom Action

Use this guide to link a path name to a feature's photo in the attribute table.

This assumes you have a column in your data containing the full path to the image you'd like to open (in this example, a field called photo_path).

Create Action

  1. Right click feature class → Properties
  2. On Actions tab:
  • Type: Open
  • Name: Open Photo
  • Action: [% "photo_path" %] (select the field from the list and click "insert field")
  1. Add to action list

Open a Photo

With the info window for a feature open, right click the photo_path field and you'll see your custom "Open Photo" action at the bottom. Now photos can be opened with one click from the attribute table using the default system image viewer.

@Hornbydd

This comment has been minimized.

Copy link

commented Mar 19, 2018

Could you provide and example when the text field contains a relative path? For example how do you create an action that opens a photo when the text field is storing "media/img1234.jpg" (minus the quotes)?

@emmaebachman

This comment has been minimized.

Copy link

commented Jul 13, 2018

If you set it up the same way as they describe, and then copy/paste the project path directly in front of the relative path in the action code, then it will open the image.
C:\Users\...\[% "photo_path" %]
The only issue with this is that you'll have to change the URL in the action if you change the project path. There should be a way to access the project path from within the program, but I haven't been able to find that yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.