Bug report #15658

map tips does not show images correctly anymore... on Linux

Added by Adam Szieberth about 8 years ago. Updated about 6 years ago.

Status:Closed
Priority:High
Assignee:-
Category:Map Tools
Affected QGIS version:2.18.11 Regression?:Yes
Operating System:Ubuntu 16.04 (possibly others) Easy fix?:No
Pull Request or Patch supplied:No Resolution:not reproducable
Crashes QGIS or corrupts data:No Copied to github as #:23581

Description

I faced with the same issue:

http://gis.stackexchange.com/questions/211117/map-tip-display-text-in-qgis-2-16-pictures-not-showing-up-anymore

Map tips are not showing images correctly; there are scrollbars instead.

My formula:

<h2> [% "filename" %] </h2>
<br>
<img src="[% "filepath" %]" width="400" />

Before (2.10.x) I saw the filename and the photo below correctly.

Attribute_table.png (100 KB) Pavel Diptan, 2017-07-19 01:18 PM

identify_features_code.png (204 KB) Pavel Diptan, 2017-07-19 01:18 PM

Map_Tips_code.png (61.5 KB) Pavel Diptan, 2017-07-19 01:18 PM

Map_Tips_empty_dialog.png (104 KB) Pavel Diptan, 2017-07-19 01:18 PM

identify_features_working.png (565 KB) Pavel Diptan, 2017-07-19 01:18 PM


Related issues

Duplicated by QGIS Application - Bug report #16401: Maptips with images stopped to work in 2.18 Closed 2017-03-31
Duplicates QGIS Application - Bug report #12141: Map Tips HTML: images added with <img src> are only shown... Closed 2015-02-06

History

#1 Updated by Adam Szieberth about 8 years ago

Enclosing content in divs worked as I posted in my answer on SE:

<div style="width:400;height:320">
<div style="height:20; margin: 0 auto;">
[% "filename" %]
</div>
<div style="height:300; margin: 0 auto;">
<img style="max-width:400px; max-height:300px;" src="[% "filepath" %]" />
</div>
</div>

However, I believe many have formatted they map tip html according to this answer (as did I):

http://gis.stackexchange.com/a/160131/44921

This issue is related to the plain and common practice mentioned by this SE answer.

#2 Updated by Alexander Bruy over 7 years ago

#3 Updated by Alexander Bruy over 7 years ago

  • OS version deleted (XP)
  • Description updated (diff)
  • Priority changed from Normal to Severe/Regression
  • Operating System deleted (Windows)

Raising priority as this is regression.

#4 Updated by Giovanni Manghi over 7 years ago

  • Affected QGIS version changed from 2.16.3 to 2.18.4
  • Target version set to Version 2.18

#5 Updated by Giovanni Manghi over 7 years ago

  • Regression? set to Yes

#6 Updated by Giovanni Manghi over 7 years ago

  • Priority changed from Severe/Regression to High

#7 Updated by Giovanni Manghi over 7 years ago

  • Easy fix? set to No

#8 Updated by Giovanni Manghi over 7 years ago

  • Status changed from Open to Closed
  • Resolution set to not reproducable

work as expected on 2.18.7

#9 Updated by Giovanni Manghi over 7 years ago

  • Affected QGIS version changed from 2.18.4 to 2.18.9
  • Status changed from Closed to Open
  • Resolution deleted (not reproducable)

seems with local image is still broken and in 2.14 was ok.

#10 Updated by Alexander Bruy over 7 years ago

  • Status changed from Open to Closed

Seems now you need to specify image size and follow strict HTML rules, then it works.

#11 Updated by Pavel Diptan over 7 years ago

Alexander Bruy wrote:

Seems now you need to specify image size and follow strict HTML rules, then it works.

Can you provide an example of working HTML code? The one specified by Adam Szieberth doesn't work.

The HTML code that used to work for me pre 2.14.x:

[%CONCAT('<img src="',"filepath",'" width="640"></img>')%]

The new HTML code as recommended above doesn't work for me:

<div style="width:400;height:320">
<div style="height:20; margin: 0 auto;">
[% "filename" %]
</div>
<div style="height:300; margin: 0 auto;">
<img style="max-width:400px; max-height:300px;" src="[% "filepath" %]" />
</div>
</div>

Below are a bunch of images trying to explain my problem as clearly as possible and my system information. Does anyone know why Map tips don't work (they are not working on a whole bunch of Linux machines, unable to test on Windows). Is there an error in the code I am using?

When using map tips, the filename of the image comes up, but the image itself is blank:

The HTML code is as specified above:

The attribute table showing filepath:

The weird thing is that identify features works:

When filepath is set to be 'Photo':

My system:

Kernel: 4.4.0-83-generic x86_64 (64 bit)
Desktop: MATE 1.14.1 Distro: Linux Mint 18 Sarah
QGIS version 2.18.10
QGIS code revision 59e0f78
Compiled against Qt 4.8.7
Running against Qt 4.8.7
Compiled against GDAL/OGR 1.11.3
Running against GDAL/OGR 1.11.3
Compiled against GEOS 3.5.0-CAPI-1.9.0
Running against GEOS 3.5.1-CAPI-1.9.1 r4246
PostgreSQL Client Version 9.5.2
SpatiaLite Version 4.3.0a
QWT Version 5.2.3
PROJ.4 Version 492
QScintilla2 Version 2.9.1

#12 Updated by Giovanni Manghi over 7 years ago

  • Affected QGIS version changed from 2.18.9 to 2.18.10
  • Subject changed from map tips does not show images correctly anymore to map tips does not show images correctly anymore... on Linux
  • Status changed from Closed to Open
  • Operating System set to Ubuntu 16.04 (possibly others)

The HTML code that used to work for me pre 2.14.x:

[...]

The new HTML code as recommended above doesn't work for me:

[...]

this snippets as also the one in the description... al works fine on Windows 2.14.16 or 2.18.10, they "just" don't work on Linux.

#13 Updated by Giovanni Manghi over 7 years ago

  • Affected QGIS version changed from 2.18.10 to 2.18.11

#14 Updated by Alexander Bruy about 7 years ago

  • Status changed from Open to Feedback

Works fine on all systems with strict HTML

<img src="file:///path/to/image.png" width=200 height=200/>

#15 Updated by Giovanni Manghi about 7 years ago

  • Resolution set to not reproducable
  • Status changed from Feedback to Closed

#16 Updated by Alexander Bruy about 7 years ago

  • Duplicates Bug report #12141: Map Tips HTML: images added with <img src> are only shown if source is a local file added

#17 Updated by Bernd Vogelgesang almost 7 years ago

Nice to finally find that this works when adding "file://" to the path.
But still it's a regression from the state before, when a simple path like it is generated e.g. from Photo2shape-plugin does not work anymore.
Neither intuitive nor to be expected.
Furthermore it's not documented anywhere, and after month of not being able to get some work done which would have relied on that function, I accidently stumbled upon this bug report.

#18 Updated by Marco Bernasocchi about 6 years ago

The most portable way to use this (assuming you have the images in the same folder as the project) currently (tested on 3.2 - ubuntu) is:

<img src="file://[%  @project_home  %]/[% "your_relative_picture_path" %]" />

Also available in: Atom PDF