My map tips are not showing images and instead show only paths in QGIS.

HTML image

Map tip

  • Welcome to GIS SE! We're a little different from other sites. We're a Q&A site, not a discussion forum. For questions that involve code we ask that you show us where you are stuck with your own code by including a code snippet in your question. There is an edit button beneath your question which will enable you to do that and a {} button that enables you to format any highlighted code (like your HTML) nicely. Please check out our short tour for more about how the site works. Thanks. – PolyGeo Mar 31 '19 at 8:15
  • This still isn't working for me. I have the following code, and it just displays a blank window. Any ideas? <img src='file:///[% @project_home %]/name_of_folder_with_images/[% 'name_of_column_in_csv_with_imagenames' %]' width='450'></img> – user10474728 Mar 25 '20 at 11:57

You should check the following points:

1) The path string must be quoted in your resulting string which is not the case in the sreenshot you provided.

2) You seem to be attempting to load local file image: your images have to be on a local or remote server.

3) (in any case u forgot it): you must activate maps tip ("Layer/Show Map Tips")

4) Here is a working example:

[% concat('<img src=\'http://localhost/images/text-letter-',right("city_name",1),'.svg\'>') %]

to have quote in the final string you must 'escape' special characters using the "\" ...

In the example I load an svg file whose name will be depending on the first letter of "city_name"

PS: a bit of formatting in the questions are always welcome ...


Three things needs to be addessed:

1) as @snaileater said, the path must be quoted
2) the ending </img> tag must not contain spaces, else is will be printed as text
3) a local file URL must start with file:\\

Here is a example displaying a local file:

[% concat('<img src=\'file:\\',"path", '\' width="400"></img>') %]

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.