Table Image in a span tag?
Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice
- Full Bleed
- Demigod
- Posts: 4736
- Joined: Sun Feb 25, 2007 11:53 am
- Location: FL
Table Image in a span tag?
Can this be done?
And, if so, can you share some sample code.
Thanks.
And, if so, can you share some sample code.
Thanks.
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."
Re: Table Image in a span tag?
This could have a couple of meanings. Table image from an MT table or table background image that appears in a span or image that appears in a span tooltip? Yes on all accounts though.
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
- Full Bleed
- Demigod
- Posts: 4736
- Joined: Sun Feb 25, 2007 11:53 am
- Location: FL
Re: Table Image in a span tag?
This.aliasmask wrote:This could have a couple of meanings. Table image from an MT table... that appears in a span tooltip
I want to be able to hover on a macrolink that will show a tooltip that has some text and an image pulled from a MT table.
Can you illustrate?Yes on all accounts though.
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."
Re: Table Image in a span tag?
I have an example here: http://forums.rptools.net/viewtopic.php ... 94#p255884
You don't actually need the <span> if you want it to display over the macrolink, but you can wrap your link with a span, but the tool tip only displays when over text and may not work over the link specifically. Then again, it may. I'll let you test it out.
Code: Select all
[H: myImage = getTableImage("imageTable",refValue)]
[H: linkText = macroLinkText(macroName, output, args, target)]
[R: output = strformat('<a href="%{linkText} title="<html><img src="%{myImage}" height=50 width=50 /><BR>Tooltip Text</html>">Optional Link Text</a>')]
Code: Select all
[H: myImage = getTableImage("imageTable",refValue)]
[H: fullLink = macroLink(text, macroName, output, args, target)]
[R: output = strformat('<span title="<html><img src="%{myImage}" height=50 width=50 /><BR>Tooltip Text</html>">%{fullLink} And some random text to test mouseover.</span>')]
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
- Full Bleed
- Demigod
- Posts: 4736
- Joined: Sun Feb 25, 2007 11:53 am
- Location: FL
Re: Table Image in a span tag?
I don't know where your example is in that link.aliasmask wrote:I have an example here: http://forums.rptools.net/viewtopic.php ... 94#p255884
Neither of the examples you showed above are working for me. Do you have any verified working code you can share?
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."
Re: Table Image in a span tag?
I forgot about using quotes in title and apparently title does not work for macrolinks, so span has to be used.
I used this code to test in my framework and it works both in chat and in a dialog:
Since you can't add a tooltip, you can just use macroLink instead of macroLinkText and replace everything from <a>...</a> with %{linkText}.
I used this code to test in my framework and it works both in chat and in a dialog:
Code: Select all
[H: myImage = tableImage("item.locations",1)]
[H: linkText = macroLinkText("testMacro@Lib:libDnD35Pathfinder","all")]
[R: output = strformat('<span title="<html><img src="%{myImage}" /><br>Tooltip Text</html>"><a href="%{linkText}">Macro Link Text</a></span>')]
[dialog("D"):{[r: output]}]
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
- Full Bleed
- Demigod
- Posts: 4736
- Joined: Sun Feb 25, 2007 11:53 am
- Location: FL
Re: Table Image in a span tag?
Thanks, I got this to work.aliasmask wrote:I forgot about using quotes in title and apparently title does not work for macrolinks, so span has to be used.
What I can't get to work now is sizing the image in the tooltip. Setting the image when using Wiki: tableImage() doesn't see to do the trick... the image fails to render in the tooltip.
And while I can set width and height in the img src it distorts the ratio... so I'd have to redo images to have even ratios.
I've seen mention on some sites about being able to use a percentage in height width... but I can't get that to work so it might be a newer parameter. But maybe it's a syntax thing.
Any idea?
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."
- Full Bleed
- Demigod
- Posts: 4736
- Joined: Sun Feb 25, 2007 11:53 am
- Location: FL
Re: Table Image in a span tag?
I actually tried redoing some images with even height/width ratios, and it still didn't work with PNG files that have translucent pixels. Apparently, when using height/width in the src tag it ignores translucent pixels. So the image continues to be distorted.Full Bleed wrote:And while I can set width and height in the img src it distorts the ratio... so I'd have to redo images to have even ratios.
EDIT: For the record... the issue was it only reading one of the fields which made it seem like translucency might have been ignored. It wasn't.
Last edited by Full Bleed on Sat Nov 04, 2017 1:16 am, edited 1 time in total.
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."
Re: Table Image in a span tag?
I know there is a getTokenWidth that will tell you the width, but I wonder if there is an undocumented function to get image dimensions. You may want to try only setting the height or width of the image and let MT scale the other dimension.
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
- Full Bleed
- Demigod
- Posts: 4736
- Joined: Sun Feb 25, 2007 11:53 am
- Location: FL
Re: Table Image in a span tag?
Unfortunately that doesn't work on table images... I could try pulling the image, saving it to a token then pulling the height and width... but that's a lot of moving parts to get that data. I actually tried a test run and couldn't get Wiki: setTokenImage() to remotely set an Image_Token.aliasmask wrote:I know there is a getTokenWidth that will tell you the width, but I wonder if there is an undocumented function to get image dimensions.
I tried. Didn't work. It defaults the unset dimension to the full size.You may want to try only setting the height or width of the image and let MT scale the other dimension.
I'm still wondering if I can use percentages in the src tag... but maybe don't know the syntax. When you get inside that sort of output line things get real hinky with the quotes, apostrophes, html codes, etc. Nothing I tried would work but I have no idea how the parser is doing things at that point in the code.
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."
Re: Table Image in a span tag?
What I would do is put the token dimensions in the table or on a lib token property, but in order to do that I would have to loop through the table and set a token with that image from the table then get the new dimensions. Then I could use a formula to set the token dimension bounds. Does the token size formatting work for the <img> tag? For example, instead of setting the height/width, just use -50 at the end of the asset\\ line in the quotes. It works for built in MT functions like input(), but if I recall it doesn't for <img>, but I may recall wrong.
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
- Full Bleed
- Demigod
- Posts: 4736
- Joined: Sun Feb 25, 2007 11:53 am
- Location: FL
Re: Table Image in a span tag?
I think I'd rather just update the template I use for the images I put in those tables and put nearly invisible pixels in the croners to set bounds that the height/width field will acknowledge... or find some custom image frame.aliasmask wrote:What I would do is put the token dimensions in the table or on a lib token property, but in order to do that I would have to loop through the table and set a token with that image from the table then get the new dimensions. Then I could use a formula to set the token dimension bounds.
I'm not sure exactly what you're asking.. but this works:Does the token size formatting work for the <img> tag? For example, instead of setting the height/width, just use -50 at the end of the asset\\ line in the quotes. It works for built in MT functions like input(), but if I recall it doesn't for <img>, but I may recall wrong.
Code: Select all
[h: groupTreasure.icon = strformat('<img alt = "Group Treasure" border = 0 src="%s" />', tblImage("CharacterSheet", 81, 60))]
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."
Re: Table Image in a span tag?
Yeah, same thing. When setting the image size with the function all it does is add -60 at the end of image link.
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
- Full Bleed
- Demigod
- Posts: 4736
- Joined: Sun Feb 25, 2007 11:53 am
- Location: FL
Re: Table Image in a span tag?
OK, I found a solution that would work with the height/width in the img src tag in your output:
When done that way it acknowledges both fields and translucency to maintain aspect ratio. It threw things off when it was basically working with one tag and not the other without the html quotes. It's ugly, but it works.
Code: Select all
height="100" width="100"
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."
Re: Table Image in a span tag?
Ah, good to know. I wouldn't think quotes would have mattered.Full Bleed wrote:OK, I found a solution that would work with the height/width in the img src tag in your output:
When done that way it acknowledges both fields and translucency to maintain aspect ratio. It threw things off when it was basically working with one tag and not the other without the html quotes. It's ugly, but it works.Code: Select all
height="100" width="100"
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools