getImage: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(17 intermediate revisions by 6 users not shown)
Line 1: Line 1:
==Function getImage==
{{MacroFunction
Returns the [[asset id]] for the image of an [[Token:Image Token]].  
|name=getImage
|version=1.3b48
|description=Returns the [[Asset ID]] for the image of a [[Token]] or [[Image Token]] found on any map in the campaign.  


===Usage===
|usage=
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
[h: asset = getImage(name)]
getImage(name)
</source>
getImage(name, size)
</syntaxhighlight>


===Examples===
'''Parameters'''
To display the image from an [[Token:image token|image token]] called "image:Map" you can do the following
{{param|name|Token name.}}  '''Note:''' Token ID cannot be used.
<source lang="mtmacro" line>
{{param|size|Image size.}}  Optional.  Specify the size of the image that is called out in the asset string returned.
 
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 [[Token:image token{{!}}image token]] called {{code|image:Map}} you can do the following:
<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:
<syntaxhighlight lang="mtmacro" line>
<img src="[r: getImage('Dragon')]"></img>
</syntaxhighlight>
 
To display the image in chat with a max dimension of 100:
<syntaxhighlight lang="mtmacro" line>
<img src="[r: getImage('Hero',100)]"></img>
</syntaxhighlight >
 
|also=[[getTokenImage]] (which you can give the size as parameter)
}}
[[Category:Miscellaneous Function]]

Latest revision as of 01:48, 21 April 2023

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)
getImage(name, size)

Parameters

  • name - Token name. Note: Token ID cannot be used.
  • size - Image size. Optional. Specify the size of the image that is called out in the asset string returned.

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>

To display the image in chat with a max dimension of 100:

<img src="[r: getImage('Hero',100)]"></img>

See Also

getTokenImage (which you can give the size as parameter)