Table Image in a span tag?

Discuss macro implementations, ask for macro help (to share your creations, see User Creations, probably either Campaign Frameworks or Drop-in Resources).

Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice

Post Reply
User avatar
Full Bleed
Demigod
Posts: 4736
Joined: Sun Feb 25, 2007 11:53 am
Location: FL

Table Image in a span tag?

Post by Full Bleed »

Can this be done?

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."

User avatar
aliasmask
RPTools Team
Posts: 9024
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Table Image in a span tag?

Post by aliasmask »

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.

User avatar
Full Bleed
Demigod
Posts: 4736
Joined: Sun Feb 25, 2007 11:53 am
Location: FL

Re: Table Image in a span tag?

Post by Full Bleed »

aliasmask wrote:This could have a couple of meanings. Table image from an MT table... that appears in a span tooltip
This.

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.
Yes on all accounts though.
Can you illustrate?
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."

User avatar
aliasmask
RPTools Team
Posts: 9024
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Table Image in a span tag?

Post by aliasmask »

I have an example here: http://forums.rptools.net/viewtopic.php ... 94#p255884

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>')]
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: 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>')]

User avatar
Full Bleed
Demigod
Posts: 4736
Joined: Sun Feb 25, 2007 11:53 am
Location: FL

Re: Table Image in a span tag?

Post by Full Bleed »

aliasmask wrote:I have an example here: http://forums.rptools.net/viewtopic.php ... 94#p255884
I don't know where your example is in that link.

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."

User avatar
aliasmask
RPTools Team
Posts: 9024
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Table Image in a span tag?

Post by aliasmask »

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:

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]}]
Since you can't add a tooltip, you can just use macroLink instead of macroLinkText and replace everything from <a>...</a> with %{linkText}.

User avatar
Full Bleed
Demigod
Posts: 4736
Joined: Sun Feb 25, 2007 11:53 am
Location: FL

Re: Table Image in a span tag?

Post by Full Bleed »

aliasmask wrote:I forgot about using quotes in title and apparently title does not work for macrolinks, so span has to be used.
Thanks, I got this to work.

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."

User avatar
Full Bleed
Demigod
Posts: 4736
Joined: Sun Feb 25, 2007 11:53 am
Location: FL

Re: Table Image in a span tag?

Post by Full Bleed »

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.
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.

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."

User avatar
aliasmask
RPTools Team
Posts: 9024
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Table Image in a span tag?

Post by aliasmask »

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.

User avatar
Full Bleed
Demigod
Posts: 4736
Joined: Sun Feb 25, 2007 11:53 am
Location: FL

Re: Table Image in a span tag?

Post by Full Bleed »

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.
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.
You may want to try only setting the height or width of the image and let MT scale the other dimension.
I tried. Didn't work. It defaults the unset dimension to the full size.

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."

User avatar
aliasmask
RPTools Team
Posts: 9024
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Table Image in a span tag?

Post by aliasmask »

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.

User avatar
Full Bleed
Demigod
Posts: 4736
Joined: Sun Feb 25, 2007 11:53 am
Location: FL

Re: Table Image in a span tag?

Post by Full Bleed »

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 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.
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.
I'm not sure exactly what you're asking.. but this works:

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."

User avatar
aliasmask
RPTools Team
Posts: 9024
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Table Image in a span tag?

Post by aliasmask »

Yeah, same thing. When setting the image size with the function all it does is add -60 at the end of image link.

User avatar
Full Bleed
Demigod
Posts: 4736
Joined: Sun Feb 25, 2007 11:53 am
Location: FL

Re: Table Image in a span tag?

Post by Full Bleed »

OK, I found a solution that would work with the height/width in the img src tag in your output:

Code: Select all

height="100" width="100"
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.
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."

User avatar
aliasmask
RPTools Team
Posts: 9024
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Table Image in a span tag?

Post by aliasmask »

Full Bleed wrote:OK, I found a solution that would work with the height/width in the img src tag in your output:

Code: Select all

height="100" width="100"
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.
Ah, good to know. I wouldn't think quotes would have mattered.

Post Reply

Return to “Macros”