Skip to content

Commit 551d0a7

Browse files
authored
online image preview, screenshots update (#731)
* online image preview, screenshots update * remove unused pics * add public sample image to use in docs public projects * add sample image to write-docs * web viewer needed only by QGIS
1 parent 60e004d commit 551d0a7

33 files changed

Lines changed: 57 additions & 11 deletions
Binary file not shown.
Binary file not shown.

src/layer/embed-image/index.md

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,47 @@
11
---
2-
description: HTML widget can be used to embed an online image in the attributes form of your survey layer.
2+
description: Preview online images in the attributes form of your survey layer using the Attachment or HTML widgets.
33
---
44

55
# How to Embed an Image
6+
Online images can be displayed in the attributes form of a survey layer. There are two options:
7+
- [Using the Attachment widget](#using-the-attachment-widget) is a straight-forward option to preview an online image in the form. Tapping the image in the form in the <MobileAppNameShort /> opens the image, so you can explore it in more detail directly in the app.
8+
- [The HTML widget](#using-the-html-widget) uses a link stored in a field to display the image. Tapping the image in the form in the <MobileAppNameShort /> opens the image in a web browser (outside of the app).
69

7-
The [**HTML widget**](../info-widgets/#html-widget) can be used to display online images in the <MobileAppNameShort />.
10+
![Mergin Maps mobile app online image preview](./mobile-embed-image.webp "Mergin Maps mobile app online image preview")
811

912
::: tip Example project available
10-
Clone <MerginMapsProject id="documentation/forms-display-images-and-files" /> to how this works.
13+
Both options are included in our example project <MerginMapsProject id="documentation/forms-display-images-and-files" />. Clone it to see how they work.
14+
:::
15+
16+
## Using the attachment widget
17+
The attachment widget can be configured to display online images in the form of a survey layer.
18+
19+
The survey layer needs to have a text field for storing the full URL link (here: `photo`).
20+
21+
1. Right-click on the survey layer, select **Properties** and go to the **Attributes form** tab.
22+
2. In the list of **Available Widgets** select the text field you want to work with (here: `photo`).
23+
3. In the **Widget Type** tab:
24+
- From the drop-down menu, select the **Attachment** widget
25+
- Store the path as **Absolute path**
26+
- Set the **Integrated Document Viewer** to use the type **Web View**, so that QGIS can display the online image in the form (this is not needed by the <MobileAppNameShort />)
27+
28+
![QGIS Attachment widget setup for online images preview](./qgis-form-attachment-widget.webp "QGIS Attachment widget setup for online images preview")
29+
30+
4. **Apply** the changes
31+
32+
Online images can now be displayed in the form, both in QGIS (left) and in <MobileAppName /> (right):
33+
![Online image preview in QGIS and in Mergin Maps mobile app](./qgis-mobile-form-online-image-attachment.webp "Online image preview in QGIS and in Mergin Maps mobile app")
34+
35+
When you click or tap on the image, it will open directly in the form and you can zoom in.
36+
37+
::: details Image preview in QGIS
38+
Some QGIS versions may not display the preview of the image correctly. This issue does not occur in <MobileAppNameShort />. Therefore we recommend trying the setup by opening the form in the <MobileAppNameShort /> to make sure it works as intended.
1139
:::
1240

41+
## Using the HTML widget <Badge text="Advanced" type="warning"/>
42+
43+
The [**HTML widget**](../info-widgets/#html-widget) can be used to display online images in the <MobileAppNameShort />.
44+
1345
Your layer should contain a text field for storing the full URL link (here: `link`).
1446

1547
To show an online image in the form, [add the HTML widget to the form](../info-widgets/) and configure it with this expression (replace `link` with the name of the appropriate field in your layer):
@@ -18,9 +50,11 @@ To show an online image in the form, [add the HTML widget to the form](../info-w
1850
<script>document.write(expression.evaluate("'<a href=\"'||attribute( @feature, 'link' )||'\"><img src=\"'||attribute( @feature, 'link' )||'\" width=300></a>'"));</script>
1951
```
2052

21-
Make sure that the HTML widget works before taking it to the field by testing it in the <MobileAppNameShort />. It should look something like this:
53+
Make sure that the HTML widget works before taking it to the field by testing it in the <MobileAppNameShort />. It should display the online image both in QGIS (left) and in the <MobileAppNameShort /> (right):
54+
55+
![HTML widget in QGIS and in Mergin Maps mobile app](./qgis-mobile-form-online-image-html.webp "HTML widget in QGIS and in Mergin Maps mobile app")
2256

23-
![HTML widget in QGIS and in Mergin Maps mobile app](./qgis-mobile-html-form.webp "HTML widget in QGIS and in Mergin Maps mobile app")
57+
When you click or tap on the image, it will open in a web browser.
2458

2559
::: details Image preview in QGIS
2660
Some QGIS versions may not display the preview of the image correctly. This issue does not occur in <MobileAppNameShort />. Therefore we recommend trying the setup by opening the form in the <MobileAppNameShort /> to make sure it works as intended.
170 KB
Loading
829 KB
Binary file not shown.
52.2 KB
Loading
468 KB
Binary file not shown.
125 KB
Loading
Binary file not shown.
86.3 KB
Loading

0 commit comments

Comments
 (0)