|
Post by Wormopolis on Apr 9, 2010 1:20:02 GMT -8
Browser Tested: IE and FF placement: global footer
Allows the user to input ANY size into the avatar dimensions. places meta data into the URL that gets extracted later. 2 variables included for maximum dimensions.
WARNING: I am not responsible for large avatars messing up your layouts.
code:
<script type="text/javascript"> <!-- // user defined avatar dimensions // v1.1 // by Wormopolis - www.wormocodes.com // keep header intact
var MAXimageHeight=500; var MAXimageWidth=500;
var affectEveryone=false; //set true if you want everyone to be able to utilize. if false, set usernames in userList variable var userList="admin|user2|user3|user4"; //seperate by |
for (pics=document.getElementsByTagName('img'),p=0;p<pics.length;p++) { if (pics[p].src.match(/redim_avH(\d+)_avW(\d+)\//i)) { nwH=RegExp.$1; nwW=RegExp.$2; pics[p].src=pics[p].src.replace(/redim_avH(\d+)_avW(\d+)\//i,'') pics[p].height=nwH; pics[p].width=nwW; } } ulrgx=new RegExp('^('+userList+')$',''); if (document.modifyForm && (affectEveryone || pb_username.match(ulrgx))) { if (modifyForm.avatarurl.value!='' && modifyForm.avatarurl.value.match(/redim_avH(\d+)_avW(\d+)\//)) { nwH=RegExp.$1; nwW=RegExp.$2; modifyForm.avatarheight.value=nwH; modifyForm.avatarwidth.value=nwW; modifyForm.avatarurl.value=modifyForm.avatarurl.value.replace(/redim_avH(\d+)_avW(\d+)\//,'') } function reDim() { if (modifyForm.avatarheight.value>100 || modifyForm.avatarwidth.value>100) { olH=(modifyForm.avatarheight.value > MAXimageHeight ? MAXimageHeight : modifyForm.avatarheight.value); olW=(modifyForm.avatarwidth.value > MAXimageWidth ? MAXimageWidth : modifyForm.avatarwidth.value); modifyForm.avatarwidth.value=modifyForm.avatarheight.value=99; nwvl=modifyForm.avatarurl.value.replace(/\/(?!\/)/,"/redim_avH"+olH+"_avW"+olW+"/"); modifyForm.avatarurl.value=nwvl; } }
if (document.addEventListener) { modifyForm.addEventListener('submit',reDim,false); } else { modifyForm.attachEvent('onsubmit',reDim); } }
// --> </script>
Preview: picture your avatar... only bigger
|
|
thronar
Not New Member
Posts: 2
thronar said 0 great things
|
Post by thronar on May 17, 2010 20:20:02 GMT -8
hello, thanks for the code.
however, I was wondering if it would be possible to make it so that only certain users can change their own avatar sizes.
|
|
|
Post by Wormopolis on May 18, 2010 1:10:57 GMT -8
give version 1.1 a shot.
|
|
thronar
Not New Member
Posts: 2
thronar said 0 great things
|
Post by thronar on May 19, 2010 13:11:30 GMT -8
thanks boss! it seems to be working fine so far
|
|