Welcome Guest [Log In] [Register]






Shoot a firework rocket ~ Winners!
Make a forum zoo!

Welcome to The Round Table. We hope you enjoy your visit.


You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
[TIP] Auto-changing avatar; To have a dynamic avatar!
Topic Started: Oct 27 2016, 04:52 PM (595 Views)
Hugo7
Member Avatar
/!\ Auto-changing avatar.

Hello,
I just had the idea to make my avatar changing automatically! :dino:
You can refresh this page several times and you'll see that my avatar is different [almost] each time!

Requirements :
- Several avatars,
- A website you own, or a friend that has a website, I mean, not a website such as these free website conceptions (blogs, Google sites, etc ...), but you'll need a place where you can upload in FTP, to upload and run your own source files (there are some hosting websites that allows you to have a website for free such as Alwaysdata or Hostinger) if you really need help, I can host that for you, but I can't host avatars of all the TRT's members :yes: ,
- A FTP client software such as FileZilla.

Let's begin by the coding.
I fully explained this PHP script for you to understand it (the explanations are the lines starting with "//")
Code:
 

<?php
// Disables the cache in order to force reloading and changing the picture.
// But it's possible that it randomly change for the same picture again.
header('Cache-Control: no-cache');


// Here, we put the list of all files, with extension, and separated with commas.
// You can add as much pictures as you want. These files must be in the same directory as this .php file.
// No matter the name of the files, it can be a number or something else. They just have to exist...
$list_of_all_pictures = array('floupflower.png','allium.png','rhino.png','polarbear.png');


// This line will select a random number from the number of input files. Do not change this line.
$random_picture = mt_rand(0,(count($list_of_all_pictures)-1));


header('Location: '.$list_of_all_pictures[$random_picture]);
// This line above will redirect the page, it's just changing the page from your .php file to the
// randomly selected picture. This works like that : this will take the N-th file of the list.
// The list is like a table :
// 1 : file1
// 2 : file2
// 3 : file3
// etc.
// So it'll take the specified file and move to this page, just as if you clicked on a link, but automatically.
?>


Copy that and paste it in Notepad (search for 'notepad' in the Windows menu), then save it as .php file. (don't close it, just save it)
Don't forget to specify "All files (*.*)" and add ".php" at the end of your file's name.
Avoid capital letters, spaces and special letters in the name of your file.
Posted Image


Now to edit a bit the code X3
Verify that the names of your avatars files do not contain capital letter, spaces and symbols.
Then go to the line containing the list, and add/remove/replace the names of the files, with the correct extension (.png, .jpg, etc)
It's this line :
$list_of_all_pictures = array('floupflower.png','allium.png','rhino.png','polarbear.png');
It's an example, replace these names of files.
In my case, I prefer having simple names like numbers for my avatars :
Posted Image


If you don't see the extensions (ex. ".png"), then select the picture and display the properties.
Posted Image

Verify that all your files' names are correctly typed in the .php file, then save your code.
You may close Notepad. (personally I use Notepad++ for the coloration but if you want you can download it)



Open FileZilla, connect to your website (or send your files to your friend who owns a website if you don't have one). It doesn't work with Google Drive and other file sharing websites because your php file needs to be executed.
Create a folder and upload your files.
(for me, it's hugoland.fr/API/avatar_alea_TRT/)
Posted Image



Go to The Round Table, in the avatar edition page (http://thezt2roundtable.com/home/?c=10)
Fill "URL to avatar" with the location of your .php file, and validate.
Posted Image


Finished! It's simple like that! Reload your profile page several times to see if it works.
If you need, I can host your files in my website, but I can't do that for everyone... :D
If you have any questions/trouble, let me know!




Edited by Hugo7, Oct 27 2016, 04:52 PM.
Offline Profile Quote Post Goto Top
 
Posted Image Xenephos
Member Avatar
ᴀ ʟɪᴛᴛʟᴇ ᴏʙsᴇssᴇᴅ

If you guys didn't notice, I do this too.
You can use the site GrumpyBumpers for a very similar result. It is not 100% viable, however, since the website is not hosted by you and can go down, leaving you with a very sad "This image Cannot Be Displayed" style avatar.

Here's the link

First, create a "username" and "password." These are just so you can store your image since only one rotating image is created per account. I suggest using a keyword for your username rather than your common username so images are identifiable much easier and store the logins somewhere if you think you'll forget them. Passwords are non-retrievable last I checked so keep that in mind.
My signature and avatar images are all created with different "usernames," which you can see when you copy the image link and paste it somewhere.

To actually make the image, I suggest uploading the images themselves to a photo-hosting website like Imgur or Photobucket. (I personally use Imgur, but any stable uploading site will do.) Don't delete the image from your account or it won't display properly.
Then, grab the urls from there and paste them into the url slots on GrumpyBumpers. Hit submit and a url will be generated that you can use as your avatar. (To get the url for a photo on Imgur, it should be on the right side under "Image Link" when a picture has been selected LIKE THIS)

Just keep in mind that because this rotating image requires this site to be viewed, it can disappear if the site goes down. This is why Hugo7's technique is more stable than mine.
Totally not speaking from experience... :V
Offline Profile Quote Post Goto Top
 
Hugo7
Member Avatar
/!\ Auto-changing avatar.

You're right, these websites are always deleting old pictures even if they are still used, leaving lots of websites without graphic content.
I suggest this French site for uploading your files, normally they never delete their content unlike Imgur and such. I use it for years.
http://xooimage.com/fr/
Edited by Hugo7, Nov 4 2016, 02:23 PM.
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · General Discussion · Next Topic »
Add Reply