3

I have a problem with displaying an image with QGIS2Web. First, I followed the procedure as given in the link below to pop some images from my photo directory:

Adding hyperlinks to pop-up data in qgis2web

Then I followed the step and typed like this:

CONCAT('<img src = "E:/haris pictures/TL0101.JPG' width="300" height="225"/>')

I put that code in my attribute table (FOTO HTML). enter image description here

After that, I used QGIS2Web plugin to produce webpage for my map and it doesn’t end up with what I expected, like this: enter image description here

Does anyone have suggestions to solve this problem?

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
Hans Noor
  • 33
  • 1
  • 3

2 Answers2

1

You are using absolute path "E:/haris pictures/TL0101.JPG", where it should be a relative path to the index.html file that you are using.

In the link that you are referring: "../images/Name.JPG", the ../images is the folder name located one level up with the relative to the index.html file.

Please note that you forgot also to add another double quote " surrounding the path of the images in your question. Also the img src tag should not be surrounded by single quote '. Here is the correct syntax I am referring from the same link you provided:

<img src = "../images/Name.JPG"  width="300" height="225" alt="Alias Name"/>
ahmadhanb
  • 40,826
  • 5
  • 51
  • 105
  • You were right, but instead of changing the field's Edit widget to Photo in the layer properties, I changed it to Web view. In there you also can control the resolution of the photo. Thank you very much! – Hans Noor Jun 06 '17 at 04:32
  • You are welcome. Glad I could help. – ahmadhanb Jun 06 '17 at 04:36
1

You don't really need to do any of this. In your layer in QGIS, create a field for the image, and set its edit widget to "Photo". The images will then automatically be exported for your webmap popups:

https://github.com/tomchadwin/qgis2web/wiki/fields,-attributes,-and-popups (last screenshot)

Tom Chadwin
  • 5,842
  • 4
  • 25
  • 48
  • It also preview an image but I can't control the resolution of the images eventhough I've edit the resoulution in the Layer > Properties > Fields. The pop up images are shown in the original size – Hans Noor Jun 06 '17 at 03:48
  • No, the images would have to be at the resolution at which you want to display them. The plugin doesn't resize them. Sorry. – Tom Chadwin Jun 06 '17 at 12:59