RPTools.net

Discussion and Support

Skip to content

It is currently Wed Nov 22, 2017 5:24 pm 






Reply to topic  [ 15 posts ] 

Previous topic | Next topic 

  Print view

Author Message
User avatar  Offline
Demigod
 
Joined: Sun Feb 25, 2007 11:53 am
Posts: 3774
Location: MD
 Post subject: Table Image in a span tag?
PostPosted: Thu Nov 02, 2017 12:44 am 
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."


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Nov 10, 2009 6:11 pm
Posts: 7949
Location: Bay Area
 Post subject: Re: Table Image in a span tag?
PostPosted: Thu Nov 02, 2017 5:19 am 
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:


Top
 Profile  
 
User avatar  Offline
Demigod
 
Joined: Sun Feb 25, 2007 11:53 am
Posts: 3774
Location: MD
 Post subject: Re: Table Image in a span tag?
PostPosted: Thu Nov 02, 2017 12:18 pm 
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.

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


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Nov 10, 2009 6:11 pm
Posts: 7949
Location: Bay Area
 Post subject: Re: Table Image in a span tag?
PostPosted: Thu Nov 02, 2017 1:24 pm 
I have an example here: viewtopic.php?f=53&t=24994#p255884

Code:
[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:
[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:


Top
 Profile  
 
User avatar  Offline
Demigod
 
Joined: Sun Feb 25, 2007 11:53 am
Posts: 3774
Location: MD
 Post subject: Re: Table Image in a span tag?
PostPosted: Thu Nov 02, 2017 4:16 pm 
aliasmask wrote:
I have an example here: viewtopic.php?f=53&t=24994#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."


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Nov 10, 2009 6:11 pm
Posts: 7949
Location: Bay Area
 Post subject: Re: Table Image in a span tag?
PostPosted: Thu Nov 02, 2017 6:09 pm 
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:
[H: myImage = tableImage("item.locations",1)]
[H: linkText = macroLinkText("testMacro@Lib:libDnD35Pathfinder","all")]
[R: output = strformat('<span title="<html><img src=&quot;%{myImage}&quot; /><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}.

_________________
Downloads:


Top
 Profile  
 
User avatar  Offline
Demigod
 
Joined: Sun Feb 25, 2007 11:53 am
Posts: 3774
Location: MD
 Post subject: Re: Table Image in a span tag?
PostPosted: Fri Nov 03, 2017 1:06 am 
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."


Top
 Profile  
 
User avatar  Offline
Demigod
 
Joined: Sun Feb 25, 2007 11:53 am
Posts: 3774
Location: MD
 Post subject: Re: Table Image in a span tag?
PostPosted: Fri Nov 03, 2017 4:14 am 
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.

_________________
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."


Last edited by Full Bleed on Sat Nov 04, 2017 12:16 am, edited 1 time in total.

Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Nov 10, 2009 6:11 pm
Posts: 7949
Location: Bay Area
 Post subject: Re: Table Image in a span tag?
PostPosted: Fri Nov 03, 2017 6:54 am 
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:


Top
 Profile  
 
User avatar  Offline
Demigod
 
Joined: Sun Feb 25, 2007 11:53 am
Posts: 3774
Location: MD
 Post subject: Re: Table Image in a span tag?
PostPosted: Fri Nov 03, 2017 1:49 pm 
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.

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


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Nov 10, 2009 6:11 pm
Posts: 7949
Location: Bay Area
 Post subject: Re: Table Image in a span tag?
PostPosted: Fri Nov 03, 2017 3:36 pm 
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:


Top
 Profile  
 
User avatar  Offline
Demigod
 
Joined: Sun Feb 25, 2007 11:53 am
Posts: 3774
Location: MD
 Post subject: Re: Table Image in a span tag?
PostPosted: Fri Nov 03, 2017 4:45 pm 
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.

Quote:
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:
[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."


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Nov 10, 2009 6:11 pm
Posts: 7949
Location: Bay Area
 Post subject: Re: Table Image in a span tag?
PostPosted: Fri Nov 03, 2017 5:13 pm 
Yeah, same thing. When setting the image size with the function all it does is add -60 at the end of image link.

_________________
Downloads:


Top
 Profile  
 
User avatar  Offline
Demigod
 
Joined: Sun Feb 25, 2007 11:53 am
Posts: 3774
Location: MD
 Post subject: Re: Table Image in a span tag?
PostPosted: Fri Nov 03, 2017 5:25 pm 
OK, I found a solution that would work with the height/width in the img src tag in your output:

Code:
height=&quot;100&quot; width=&quot;100&quot;


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


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Nov 10, 2009 6:11 pm
Posts: 7949
Location: Bay Area
 Post subject: Re: Table Image in a span tag?
PostPosted: Fri Nov 03, 2017 6:11 pm 
Full Bleed wrote:
OK, I found a solution that would work with the height/width in the img src tag in your output:

Code:
height=&quot;100&quot; width=&quot;100&quot;


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.

_________________
Downloads:


Top
 Profile  
 
Display posts from previous:  Sort by  
Reply to topic  [ 15 posts ] 

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:

Who is online

In total there is 1 user online :: 0 registered, 0 hidden and 1 guest (based on users active over the past 5 minutes)
Most users ever online was 243 on Sun Nov 04, 2012 6:14 am

Users browsing this forum: No registered users and 1 guest





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

Style based on Andreas08 by Andreas Viklund

Style by Elizabeth Shulman