# llSetLinkMedia

*LSL function*

```lsl
integer integer llSetLinkMedia(integer link, integer face, list params);
```

- `integer link`: Link number (1 for root, >1 for children) or a LINK_* flag.
- `integer face`: Face number (side) of the prim.
- `list params`: A set of property-value pairs (in no particular order) specifying media parameters, or a PrimMediaParams dictionary.

- Returns: `integer`
- Energy: 10

Set the media **params** for a particular **face** on the **link**ed prim(s) without a delay.

Returns an [integer](https://wiki.secondlife.com/wiki/integer) that is a STATUS\_\* flag which details the success/failure of the operation(s).

```lsl title="How to use" frame="terminal"
integer result = llSetLinkMedia(0, 0, []);
```

## Specification

Constant group [PrimMediaParam](/constants/groups/PrimMediaParam/):

```lsl
PRIM_MEDIA_ALT_IMAGE_ENABLE = 0
PRIM_MEDIA_AUTO_LOOP = 4
PRIM_MEDIA_AUTO_PLAY = 5
PRIM_MEDIA_AUTO_SCALE = 6
PRIM_MEDIA_AUTO_ZOOM = 7
PRIM_MEDIA_CONTROLS = 1
PRIM_MEDIA_CURRENT_URL = 2
PRIM_MEDIA_FIRST_CLICK_INTERACT = 8
PRIM_MEDIA_HEIGHT_PIXELS = 10
PRIM_MEDIA_HOME_URL = 3
PRIM_MEDIA_PERMS_CONTROL = 14
PRIM_MEDIA_PERMS_INTERACT = 13
PRIM_MEDIA_WHITELIST = 12
PRIM_MEDIA_WHITELIST_ENABLE = 11
PRIM_MEDIA_WIDTH_PIXELS = 9
```

| Constant | Type | Value | Description |
| --- | --- | --- | --- |
| [STATUS_OK](/constants/STATUS_OK/) | integer | `0` | Result of function call was success |
| [STATUS_MALFORMED_PARAMS](/constants/STATUS_MALFORMED_PARAMS/) | integer | `1000` | Function was called with malformed parameters |
| [STATUS_TYPE_MISMATCH](/constants/STATUS_TYPE_MISMATCH/) | integer | `1001` | Argument(s) passed to function had a type mismatch |
| [STATUS_BOUNDS_ERROR](/constants/STATUS_BOUNDS_ERROR/) | integer | `1002` | Argument(s) passed to function had a bounds error |
| [STATUS_NOT_FOUND](/constants/STATUS_NOT_FOUND/) | integer | `1003` | Object or other item was not found |
| [STATUS_NOT_SUPPORTED](/constants/STATUS_NOT_SUPPORTED/) | integer | `1004` | Feature not supported |
| [STATUS_INTERNAL_ERROR](/constants/STATUS_INTERNAL_ERROR/) | integer | `1999` | An internal error occurred |
| [STATUS_WHITELIST_FAILED](/constants/STATUS_WHITELIST_FAILED/) | integer | `2001` | Whitelist Failed |

<table>
	<tr>
		<th>Success/Failure Flags</th>
		<th></th>
		<th colspan="6">Description</th>
	</tr>
</table>

| Constant | Type | Value | Description |
| --- | --- | --- | --- |
| [PRIM_MEDIA_ALT_IMAGE_ENABLE](/constants/PRIM_MEDIA_ALT_IMAGE_ENABLE/) | integer | `0` |  |
| [PRIM_MEDIA_CONTROLS](/constants/PRIM_MEDIA_CONTROLS/) | integer | `1` |  |
| [PRIM_MEDIA_CONTROLS_STANDARD](/constants/PRIM_MEDIA_CONTROLS_STANDARD/) | integer | `0` | Standard web navigation controls. |
| [PRIM_MEDIA_CONTROLS_MINI](/constants/PRIM_MEDIA_CONTROLS_MINI/) | integer | `1` | Mini web navigation controls; does not include an address bar. |
| [PRIM_MEDIA_CURRENT_URL](/constants/PRIM_MEDIA_CURRENT_URL/) | integer | `2` |  |
| [PRIM_MEDIA_HOME_URL](/constants/PRIM_MEDIA_HOME_URL/) | integer | `3` |  |
| [PRIM_MEDIA_AUTO_LOOP](/constants/PRIM_MEDIA_AUTO_LOOP/) | integer | `4` |  |
| [PRIM_MEDIA_AUTO_PLAY](/constants/PRIM_MEDIA_AUTO_PLAY/) | integer | `5` |  |
| [PRIM_MEDIA_AUTO_SCALE](/constants/PRIM_MEDIA_AUTO_SCALE/) | integer | `6` |  |
| [PRIM_MEDIA_AUTO_ZOOM](/constants/PRIM_MEDIA_AUTO_ZOOM/) | integer | `7` |  |
| [PRIM_MEDIA_FIRST_CLICK_INTERACT](/constants/PRIM_MEDIA_FIRST_CLICK_INTERACT/) | integer | `8` |  |
| [PRIM_MEDIA_WIDTH_PIXELS](/constants/PRIM_MEDIA_WIDTH_PIXELS/) | integer | `9` |  |
| [PRIM_MEDIA_HEIGHT_PIXELS](/constants/PRIM_MEDIA_HEIGHT_PIXELS/) | integer | `10` |  |
| [PRIM_MEDIA_WHITELIST_ENABLE](/constants/PRIM_MEDIA_WHITELIST_ENABLE/) | integer | `11` |  |
| [PRIM_MEDIA_WHITELIST](/constants/PRIM_MEDIA_WHITELIST/) | integer | `12` |  |
| [PRIM_MEDIA_PERMS_INTERACT](/constants/PRIM_MEDIA_PERMS_INTERACT/) | integer | `13` |  |
| [PRIM_MEDIA_PERMS_CONTROL](/constants/PRIM_MEDIA_PERMS_CONTROL/) | integer | `14` |  |

<table>
	<tr>
		<th colspan="2">Parameter</th>
		<th colspan="2">Additional Parameters</th>
		<th colspan="6">Description</th>
	</tr>
	<tr>
		<td colspan="2">\[ [integer](https://wiki.secondlife.com/wiki/integer) **boolean** \]</td>
		<td colspan="6">Sets the default image state (the image that the user sees before a piece of media is active) for the chosen face. The default image is specified by Second Life's server for that media type. **Note:** This flag is not currently implemented.</td>
	</tr>
	<tr>
		<td colspan="2">\[ [integer](https://wiki.secondlife.com/wiki/integer) **control** \]</td>
		<td colspan="6">Sets the style of controls. Can be either [PRIM_MEDIA_CONTROLS_STANDARD](/constants/PRIM_MEDIA_CONTROLS_STANDARD/) or [PRIM_MEDIA_CONTROLS_MINI](/constants/PRIM_MEDIA_CONTROLS_MINI/).</td>
	</tr>
	<tr>
		<th colspan="2">**controls** Flags</th>
		<th colspan="6">Description</th>
	</tr>
	<tr>
		<td colspan="2">\[ [string](https://wiki.secondlife.com/wiki/string) **current_url** \]</td>
		<td colspan="6">Sets the current url displayed on the chosen face. Changing this URL causes navigation. 1024 characters Max</td>
	</tr>
	<tr>
		<td colspan="2">\[ [string](https://wiki.secondlife.com/wiki/string) **home_url** \]</td>
		<td colspan="6">Sets the home url for the chosen face. 1024 characters max</td>
	</tr>
	<tr>
		<td colspan="2">\[ [integer](https://wiki.secondlife.com/wiki/integer) **boolean** \]</td>
		<td colspan="6">Sets whether auto-looping is enabled.</td>
	</tr>
	<tr>
		<td colspan="2">\[ [integer](https://wiki.secondlife.com/wiki/integer) **boolean** \]</td>
		<td colspan="6">Sets whether the media auto-plays when a Resident can view it.</td>
	</tr>
	<tr>
		<td colspan="2">\[ [integer](https://wiki.secondlife.com/wiki/integer) **boolean** \]</td>
		<td colspan="6">Sets whether auto-scaling is enabled. Auto-scaling forces the media to the full size of the texture.</td>
	</tr>
	<tr>
		<td colspan="2">\[ [integer](https://wiki.secondlife.com/wiki/integer) **boolean** \]</td>
		<td colspan="6">Sets whether clicking the media triggers auto-zoom and auto-focus on the media.</td>
	</tr>
	<tr>
		<td colspan="2">\[ [integer](https://wiki.secondlife.com/wiki/integer) **boolean** \]</td>
		<td colspan="6">

			Sets what happens when someone click on a playing, but unfocused media face:

			- [TRUE](/constants/TRUE/): Does the same thing a focused media face does, and forwards the click to the web browser.
			- [FALSE](/constants/FALSE/): Focuses the media prim so that future clicks are forwarded to the web browser.

			**Note:** Viewer settings affect this flag. It works by default on most prims.

		</td>
	</tr>
	<tr>
		<td colspan="2">\[ [integer](https://wiki.secondlife.com/wiki/integer) **width** \]</td>
		<td colspan="6">Sets the width of the media in pixels.</td>
	</tr>
	<tr>
		<td colspan="2">\[ [integer](https://wiki.secondlife.com/wiki/integer) **height** \]</td>
		<td colspan="6">Sets the height of the media in pixels.</td>
	</tr>
	<tr>
		<td colspan="2">\[ [integer](https://wiki.secondlife.com/wiki/integer) **boolean** \]</td>
		<td colspan="6">Sets whether navigation is restricted to URLs in [PRIM_MEDIA_WHITELIST](/constants/PRIM_MEDIA_WHITELIST/).</td>
	</tr>
	<tr>
		<td colspan="2">\[ [string](https://wiki.secondlife.com/wiki/string) **CSV** \]</td>
		<td colspan="6">Sets the whitelist as a string of [escaped](/functions/llEscapeURL/), comma-separated URLs. This string can hold up to 64 URLs or 1024 characters, whichever comes first.</td>
	</tr>
	<tr>
		<td colspan="2">\[ [integer](https://wiki.secondlife.com/wiki/integer) **perms** \]</td>
		<td colspan="6">

			Sets the permissions mask that control who can interact with the object:

			- [PRIM_MEDIA_PERM_NONE](/constants/PRIM_MEDIA_PERM_NONE/)
			- [PRIM_MEDIA_PERM_OWNER](/constants/PRIM_MEDIA_PERM_OWNER/)
			- [PRIM_MEDIA_PERM_GROUP](/constants/PRIM_MEDIA_PERM_GROUP/)
			- [PRIM_MEDIA_PERM_ANYONE](/constants/PRIM_MEDIA_PERM_ANYONE/)

		</td>
	</tr>
	<tr>
		<td colspan="2">\[ [integer](https://wiki.secondlife.com/wiki/integer) **perms** \]</td>
		<td colspan="6">

			Sets the permissions mask that control who can see the media control bar above the object:

			- [PRIM_MEDIA_PERM_NONE](/constants/PRIM_MEDIA_PERM_NONE/)
			- [PRIM_MEDIA_PERM_OWNER](/constants/PRIM_MEDIA_PERM_OWNER/)
			- [PRIM_MEDIA_PERM_GROUP](/constants/PRIM_MEDIA_PERM_GROUP/)
			- [PRIM_MEDIA_PERM_ANYONE](/constants/PRIM_MEDIA_PERM_ANYONE/)

		</td>
	</tr>
</table>

## Caveats

- If prim media is not already on this object, it will be added.
- If prim media is newly added to this object, **params** not specified take their default value.
- If prim media is already on this object, **params** not specified are unchanged.
- About `PRIM_MEDIA_WIDTH_PIXELS` (`width`) and `PRIM_MEDIA_HEIGHT_PIXELS` (`height`) ...
- Both `width` and `height` must be specified for either to work. They narrow the texture space while inversely widening the aperture, i.e. smaller values "zoom in."
- If `width` and `height` are not specified, the function assumes 1024 for each.
- When `PRIM_MEDIA_AUTO_SCALE` is `TRUE`, any value for `width` and `height` that is not precisely 2<sup>*n*</sup> where 0 ≤ *n* &lt; 12 will be "rounded up" to the next value, i.e. setting `PRIM_MEDIA_WIDTH_PIXELS` to 257 has the same effect as setting it to 512. Any value outside the range of \[0, 2048\] will cause the function to shout a message to `DEBUG_CHANNEL` and fail. Using 0 (zero) results in the default value being used, which is 1024.
- &lt;strike>It might be helpful to think of `width` and `height` as setting your "screen size." If the media is smaller than this "screen," there will be empty space below and/or to the right of the media. If the media is larger than this "screen," scroll bars will be made visible. Re-scaling the prim without altering the face's *Horizontal scale,* *Vertical scale,* *Horizontal offset,* and *Vertical offset* will only distort (stretch/compress) the media.&lt;/strike><sub>*Pending review. - NM*</sub>
- `width` and `height` scaled larger than 1024 pixels will require the texture backdrop to be resized to fit. (See [Useful Snippets](#useful-snippets))
- If resized to fit, the resulting view will cut off scrolled content outside the bounds making it impossible to be viewed.

## Helper functions

```lsl
//-- expand media textures greater than 1024 pixel in a direction to fit the media face
//-- does exactly what the "align" button does in the edit window
//-- original by Edelman Linden (or Kate Linden), tweaked by Void Singer
uExpandMediaTexture( integer vIntWidth, integer vIntHeight, integer vIntFace ){
    integer vIntTemp;
    vector  vSizScale;

    while (vIntWidth >> ++vIntTemp);
    vSizScale.x = vIntWidth / (float)(1 << vIntTemp);
    vIntTemp = 0;
    while (vIntHeight >> ++vIntTemp);
    vSizScale.y = vIntHeight / (float)(1 << vIntTemp);
    llSetLinkPrimitiveParamsFast( LINK_THIS,
                                  [PRIM_TEXTURE, vIntFace] +
                                  llListReplaceList( llGetLinkPrimitiveParams(LINK_THIS, [PRIM_TEXTURE, vIntFace] ),
                                                    [vSizScale, ((vSizScale - <1.0, 1.0, 0.0>) / 2.0)],
                                                    1,
                                                    2 ) );
}
```

## History

Date of Release [10/08/2011](https://wiki.secondlife.com/wiki/Release_Notes/Second_Life_Server/11#11-08-10-238207)

## Known issues

From the issue templates included by the wiki article:

- SVC-7422 (bug): ll\*LinkMedia functions do not work with LINK\_\* flags

## See also

### Functions

- [llSetPrimMediaParams](/functions/llSetPrimMediaParams/)
- [llGetLinkMedia](/functions/llGetLinkMedia/)
- [llClearLinkMedia](/functions/llClearLinkMedia/)

### Articles

- [User:Kelly Linden/lsl hacks](https://wiki.secondlife.com/wiki/User:Kelly_Linden/lsl_hacks)

---

*Source: [LlSetLinkMedia](https://wiki.secondlife.com/wiki/LlSetLinkMedia) on the Second Life Wiki. Content from the Second Life Wiki articles LlSetLinkMedia (revision 1198402, 2015-12-18), Template:LSL Constants/PrimMedia/Controls (revision 1160766, 2012-01-08), Template:LSL Constants/PrimMedia (revision 1218888, 2026-06-05), Template:LSL Constants/ReturnStatus (revision 1185325, 2013-12-19), Template:LSL Function/face (revision 1175878, 2013-01-06), Template:LSL Function/link (revision 1216622, 2024-05-04) and Template:Issues/SVC-7422 (revision 1167333, 2012-05-16), CC BY-SA 3.0.*

---

From lsl.dev: https://lsl.dev/functions/llSetLinkMedia/
