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?


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"/>
  • 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 6 '17 at 4:32
  • You are welcome. Glad I could help.
    – ahmadhanb
    Jun 6 '17 at 4:36

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)

  • 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 6 '17 at 3: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. Jun 6 '17 at 12:59

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.