Michael (masterslacker) wrote in component_help,
Michael
masterslacker
component_help

Randomized Userpic in Profile Component

The original version of the random userpic tutorial can be found HERE, on the journal of dianna_wills. Currently her journal is inaccessible so I am posting this to the community so that it will always be accessible. I've changed it a little, so that it can be an enhancement to the Editing the Profile Component tutorial.
----------

Step 1: Copy the code from the Editing the Profile Component tutorial.

Step 2: At the start of the function (after the function definition, and before the print_comp_header() call), you will need to insert a few lines to decide on a random userpic. You'll need to change the numbers in the strings to match the numbers for your userpics. To get these, load up your userpics page, and then check the properties for each image, and use the URL for each image as a new line below. You do this for as many images as you want to include. The lines to insert at the top are:
    var string[] pic;
    $pic[0]="http://userpic.livejournal.com/9103901/1362046"; # example
    $pic[1]="http://userpic.livejournal.com/9015302/1362046"; # example
    $pic[2]="Just keep on adding new lines for each of your userpics";
    var int randpic = rand(0, ((size $pic) - 1));


Step 3: Seven lines into the html you'll see a long line, and towards the end, there's a small part of it that says $p.journal.default_pic. Change that segment to be:
   <img src="$pic[$randpic]" />

This will give you a random userpic in your profile component.
Tags: !tutorial, *account level: paid/perm, user: masterslacker
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic
  • 17 comments