SID-01459: Automatically assign profile pictures
| Status: |
Answered |
TWiki version: |
5.1.1 |
Perl version: |
5.6 |
| Category: |
CategoryRegistration |
Server OS: |
Ububtu |
Last update: |
14 years ago |
Hello All,
I was wondering if there was a way to assign a profile picture automatically. Let me explain:
1. Users register with a company email address in the form
FirstnameLastname@companyPLEASENOSPAM.com
2. At an other site, there is a public photo of the users. For instance there is website2.company.com/FirstnameLastname.jpg
3. I would like to automatically grab the photo from website2 and assign it to the Twiiki profile information.
Thanks, KB.
--
KarthikB - 2012-05-07
Discussion and Answer
Two options.
1. Point to those images: Modify the user profile header and
UserList and other reports that show the profile picture to use the external image instead of the one attached to the profile page. Example:
<img src="http://website2.company.com/%INCLUDINGTOPIC%.jpg" width="200" border="0" alt="" />
2. Copy the image over to TWiki. This requires a plugin or an external script. When a user registers in TWiki, the plugin or script gets the image from the external site (using wget or the like) and places it in the user's attachment directory. Say, JimmyNeutron is registering. At that time you get the image and place it in the attachment directory as
twiki/pub/Main/JimmyNeutron/picture.jpg. Then you update the form field called Image to contain
picture.jpg.
--
PeterThoeny - 2012-05-08
Thanks. That is what I was converging too. What variable do I use to select the email id the user used when registering. The picture is names the same as the email id.
--
KarthikB - 2012-05-08
In case someone else is trying to do the same thing, here is what I did to solve the problem:
Edited
UserList.txt and added this:
format="| <a href='%SCRIPTURLPATH{view}%/$web/$topic' title='View profile page'> <img src='http://website2/emp_pic/upload_pic/$percntCALC{\"$LISTITEM(1, $SPLIT(@,$percntUSERINFO{\"$formfield(FirstName)$formfield(LastName)\" format=\"$emails\"}$percnt))\"}$percnt.jpg'> </a> | [[$topic][$formfield(FirstName)%BR%$formfield(LastName)]] | $percntICON{mail}$percnt $formfield(Email) $percntIF{ \"'$formfield(Telephone)'!=''\" then='%BR% $percntICON{phone}$percnt $formfield(Telephone)' }$percnt $percntIF{ \"'$formfield(Mobile)'!=''\" then='%BR% $percntICON{mobile}$percnt $formfield(Mobile)' }$percnt $percntIF{ \"'$formfield(SkypeID)'!=''\" then='%BR% $percntICON{skype}$percnt $formfield(SkypeID)' }$percnt | $formfield(Department) | $formfield(Organization) | $formfield(Location) | $formfield(Country) | $percntUSERINFO{\"$formfield(FirstName)$formfield(LastName)\" format=\"$emails\"}$percnt |" excludetopic="*Template"
and edited
UserProfileHeader.txt to include this:
<a href="%SCRIPTURL{view}%/%WEB%/ChangeProfilePicture?wikiname=%INCLUDINGTOPIC%" title="%MAKETEXT{"Change profile picture"}%" rel="nofollow">
<img src="http://website2/emp_pic/upload_pic/%CALC{"$LISTITEM(1, $SPLIT(@,%USERINFO{"%INCLUDINGTOPIC%" format="$emails"}%)} )"}%.jpg" width="200" border="0" alt="" /></a>
--
KarthikB - 2012-05-08
So the image name is the same like the topic name of the user once registered. To refer to the topic name in the user profile page use
%TOPIC%, in the UserProfileHeader page use
%INCLUDINGTOPIC%. To refer to the topic name in a search format use
$topic.
--
PeterThoeny - 2012-05-08
I thought I fixed it - but apparently not.
The trouble is the images are rendering only if I log in as the admin user. If I log in as a regular user or view it as a Guest, I see no image.
Any idea what is going on? Thanks.
--
KarthikB - 2012-05-08
It is impossible to help without more details. What is the image link you use?
--
PeterThoeny - 2012-05-09
Peter,
The image link is from a server (intranet) inside the company and as such is impossible to access from outsite.
Here are the details:
- Edited /var/www/twiki/data/Main/UserList.txt and /var/www/twiki/data/Main/UserProfileHeader.txt files to have these lines:
<img src="http://intranet/emp_pic/upload_pic/%CALC{"$LISTITEM(1, $SPLIT(@,%USERINFO{"%INCLUDINGTOPIC%" format="$emails"}%)} )"}%.jpg" width="200" border="0" alt="" /></a>
- On intranet, no login is required to see the photos.
- When logged into TWiki, I can access the photos. When I log out, the same page shows no photos.
- Could it be that the spreadsheet plugin does not work when logged out?
Thanks.
Karthik
--
KarthikB - 2012-05-09
Uncheck the
{AntiSpam}{HideUserDetails} flag in configure.
--
PeterThoeny - 2012-05-09
If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.