FANDOM


UserAvatarLink is a script that turns the avatar image inserted by User Avatar Finder into a clickable link. The link is to a user-specific page belonging to the same user as the avatar (ex. user page or message wall). In order to do this, at most two additional attributes must be added to a User Avatar Finder placeholder.

Installation

Dependencies

  • User Avatar Finder

Configuration

The configuration option (namespace) for this script simply provides a means of altering the default namespace associated with the data-useravatarlink-namespace attribute. The option is a property of the script's configuration object which can be created in a community's JS with the following lines of code.

if (!window.andrewds1021) {
    window.andrewds1021 = {
        user_avatar_link: {}
    };
} else if (!window.andrewds1021.user_avatar_link) {
    window.andrewds1021.user_avatar_link = {};
}

The configuration option should be set to a string that matches a namespace such that Namespace + ":" + Username is a valid page. To set the default namespace, place a line of code like the following below the code creating the script's configuration object.

window.andrewds1021.user_avatar_link.namespace = "Message Wall";

In the above example, the default namespace is set to Message Wall. Therefore, the script will attempt to link to the user's message wall. If the configuration setting is not set, the script will use User as the default namespace.

Usage

In order to create the link, the script must know the namespace and user to link to. This information is provided by adding two attributes to the User Avatar Finder placeholder.

data-useravatarlink-namespace

This attribute is used to change the target namespace to something other than the default. As with the configuration setting, the value should a a string that matches a recognized namespace such that Namepsace + ":" + Username is a valid page.

data-useravatarlink-username

This attribute is used to specify the target user. It should be the target user's username as a string such that Namepsace + ":" + Username is a valid page.

Template:UserAvatarLink

Template:UserAvatarLink is a template that may be copied to a wiki to increase the ease of using this script. The template is a modified version of the template provided for User Avatar Link. The template uses unnamed parameters as summarized in the following table.

Parameter Use
1 target user
2 size of avatar
3 target namespace

Note that this template does not perfectly replicate the behavior of the template for User Avatar Finder. The reason is that a correction has been incorporated for when the template is called without a specified size.

Example

The following examples assume that the script's configuration setting has not been set and, therefore, that User is the default namespace. If you are not able to see the results, you may have disabled the DemoScripts gadget. Go to your preferences and verify that DemoScripts is enabled (the box should have a check mark in it).

Example Default

Template call:

{{UserAvatarLink}}

Result:

Example 1

Template call:

{{UserAvatarLink|Andrewds1021}}

Result:

Example 2

Template call:

{{UserAvatarLink|Andrewds1021|100}}

Result:

Example 3

Template call:

{{UserAvatarLink|Andrewds1021||User_talk}}

Result:

Example 4

Template call:

{{UserAvatarLink|Andrewds1021|100|User_talk}}

Result:

See also

Text above can be found here (edit)
Community content is available under CC-BY-SA unless otherwise noted.

Fandom may earn an affiliate commission on sales made from links on this page.

Stream the best stories.

Fandom may earn an affiliate commission on sales made from links on this page.

Get Disney+