I'm a new user to GIS and am learning as I go. I'm using QGIS 3.2 on a MacBook Pro. I have a delimited text layer with a number of points for which I've set up Map Tips. I want information to come up for each point including a hyperlinked image. The images are pictures of samples taken. The image file could be named in either of two formats, depending on whether or not the sample was sent off for assay. If it was, the point will have a "Tag_Num" and the image will be named with that Tag Number. If it was not, the image will be named for the "Sample_Name", and "Tag_Num" will be NULL. "Tag_Num" and "Sample_Name" are fields in the attribute table, to be clear. The path is the same for all images.
I've tried a couple different ways of doing this, neither works. Here's what I've tried...
<div align="center" style="width:505"><b>[% "Sample Name" %]</b></div>
<br />
<div style="width:450; line-height: 1.2">
<b>Date: </b>[% "Date" %]<br />
<b>Tag Number: </b>[% "Tag_Num" %]<br />
<b>Disposition: </b>[% "Disposition" %]<br />
<b>Location: </b>[% "Latitude" %], [% "Longitude" %]<br />
<b>Sample Type: </b>[% "Sample Type" %]<br />
<br />
<b>Location Description: </b>[% "Loc_Desc" %]<br />
<br />
<b>Sample Description: </b>[% "Sample_Desc" %]<br />
</div><br />
<b>Sample Photo: </b><br />
[% CASE WHEN "Tag_Num" IS NOT NULL THEN '<a href='File:///Users/wsmb/Documents/WCM/Prospecting/Sampling/Photos/Samples/[% "Tag_Num" %].jpg'><img src='File:///Users/wsmb/Documents/WCM/Prospecting/Sampling/Photos/Samples/[% "Tag_Num" %].jpg' width='480' /></a>' ELSE '<a href='File:///Users/wsmb/Documents/WCM/Prospecting/Sampling/Photos/Samples/[% "Sample Name" %].jpg'><img src='File:///Users/wsmb/Documents/WCM/Prospecting/Sampling/Photos/Samples/[% "Sample Name" %].jpg' width='480' /></a>' END CASE %]
Using that route, I get this output in the map tips window:
VC18JW036
Date: 08/28/2018
Tag Number: M123456
Disposition: blah
Location: xx.xxxxx, -xxx.xxxxx
Sample Type: bleh
Location Description: blah blah
Sample Description: blah blah blah
Sample Photo: [% CASE WHEN "Tag_Num" IS NOT NULL THEN '' ELSE '' END CASE %]
For whatever reason, the "[% CASE WHEN..." all comes across as text. It does load and properly hyperlink the image(s) if they exist, but it tries to load both. It will just be the empty image frame if the image file does not exist.
I also tried it this way...
<a href="File:///Users/wsmb/Documents/WCM/Prospecting/Sampling/Photos/Samples/[%case when "Tag_Num" is not null then '[% "Tag_Num" %]' else '[% "Sample Name" %]' end %].jpg"><img src="File:///Users/wsmb/Documents/WCM/Prospecting/Sampling/Photos/Samples/[%case when "Tag_Num" is not null then '[% "Tag_Num" %]' else '[% "Sample Name" %]' end %].jpg" width="480"></a>
This way, I get a single blank image frame as though the image is nonexistent, but I do not see any of the "[% case when..." arguments coming over as text...
As I said, I'm new to this, so I'm guessing it's a syntax error, I'm just typing something in a way I'm not supposed to. Or perhaps I cannot nest [% [% %] %] those, or am erring in the way I nest my quotation marks?