getImage: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(16 intermediate revisions by 6 users not shown)
Line 2: Line 2:
|name=getImage
|name=getImage
|version=1.3b48
|version=1.3b48
|description=Returns the [[asset id]] for the image of an [[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=
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
getImage(name)
getImage(tokenRef)
</source>
getImage(tokenRef, size)
</syntaxhighlight>
 
'''Parameters'''
{{param|tokenRef|Either the token [[getSelected|{{code|id}}]] or [[getTokenName|Token Name]] of the token for which you want to retrieve the token image, defaults to the [[Current Token]].}}
{{param|size|Image size.}}  Optional.  Specify the size of the image that is called out in the asset string returned.
 
{{Note|Token IDs are unique, but Token Names can be duplicated. Using Token Name when more than one token has the same name can produce unexpected results.}}


|example=
|example=
To display the image from an [[Token:image token{{!}}image token]] called "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 >
}}
Note that an "image:token" can be retrieved from ANY map (so it does NOT have to be on the current map.


Alternatively this can be used to retrieve a normal token, which MUST be on the same map:
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>
}}


To display the image in chat with a max dimension of 100:
<syntaxhighlight lang="mtmacro" line>
<img src="[r: getImage('Hero',100)]"></img>
</syntaxhighlight >


see 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]]

Latest revision as of 23:59, 10 May 2024

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

Parameters

  • tokenRef - Either the token id or Token Name of the token for which you want to retrieve the token image, defaults to the Current Token.
  • size - Image size. Optional. Specify the size of the image that is called out in the asset string returned.


Token IDs are unique, but Token Names can be duplicated. Using Token Name when more than one token has the same name can produce unexpected results.

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)