getImage: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
m (Tweaking page layout and typography)
No edit summary
Line 2: Line 2:
|name=getImage
|name=getImage
|version=1.3b48
|version=1.3b48
|description=Returns the [[asset id]] for the image of a [[Token]] or [[Image Token]].  
|description=Returns the [[asset id]] for the image of a [[Token]] or [[Image Token]] found on any map in the campaign.  


|usage=
|usage=
{{Clarify|There's no real parameter description.<br />
<syntaxhighlight lang="mtmacro" line>
Error handling on duplicates should be pointed out.}}
<source lang="mtmacro" line>
getImage(name)
getImage(name)
</source>
</syntaxhighlight>


'''Note:''' Token ID does NOT work, only token name works.
'''Parameters'''
{{param|name|Token name.}}  '''Note:''' Token ID is not allowed.
 
If identical token names appear on multiple maps, it may be difficult (or impossible) to select a specific token image using this function.


Note that token images can be retrieved from ANY map (so they do NOT have to be on the current map).  If identical token names appear on multiple maps, it may be difficult (or impossible) to select a specific token image using this function.
|example=
|example=
To display the image from an [[Token:image token{{!}}image token]] called {{code|image:Map}} you can do the following:
To display the image from an [[Token:image token{{!}}image token]] called {{code|image:Map}} you can do the following:
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
<img src="[r: getImage('image:Map')]"></img>
<img src="[r: getImage('image:Map')]"></img>
</source>
</syntaxhighlight >


Alternatively this can be used to retrieve a normal token:
Alternatively this can be used to retrieve a normal token:
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
<img src="[r: getImage('Dragon')]"></img>
<img src="[r: getImage('Dragon')]"></img>
</source>
</syntaxhighlight>
|also=[[getTokenImage]] (which you can give the size as parameter)
|also=[[getTokenImage]] (which you can give the size as parameter)
}}
}}
[[Category:Miscellaneous Function]]
[[Category:Miscellaneous Function]]

Revision as of 16:46, 21 August 2021

getImage() Function

Introduced in version 1.3b48
Returns the asset id for the image of a Token or Image Token found on any map in the campaign.

Usage

getImage(name)

Parameters

  • name - Token name. Note: Token ID is not allowed.

If identical token names appear on multiple maps, it may be difficult (or impossible) to select a specific token image using this function.

Example

To display the image from an image token called image:Map you can do the following:
<img src="[r: getImage('image:Map')]"></img>

Alternatively this can be used to retrieve a normal token:

<img src="[r: getImage('Dragon')]"></img>

See Also

getTokenImage (which you can give the size as parameter)