View Full Version : Proportionally Auto Resize User Avatar
toolblast
04-17-2006, 10:00 PM
PROPORTIONALLY AUTO RESIZE USER AVATAR PLUGIN
Last updated: April 18th - newest file is 'PluginFiles.zip'
What does this plugin do?
It will allow you to place the logged in user's avatar in your forum header or navbar and then set a predefined maximum width and height that the user's avatar can go in. Then, using PHP, an automatic resize will occur that will NOT stretch the image.
Update: this hack doesn't work everywhere like previously stated in earlier versions. Some templates in vbulletin do not render global variables making the plugin not show the avatar. One of these templates is the postbit template. If you put '$useravatar' in that template nothing will happen. Why? I'm not sure, and if anyone knows how to make it work please share!
What is the point of this plugin?
If you want the user to be able to upload a large avatar that will appear on the postbit, but in the forum login info part in the header you want to show their avatar, but at a smaller size than the original (without editing the original uploaded file and without stretching it). This is for you.
Installation:
Extremely simple. Simply upload plugin from the plugin manager area of your VBulletin Admin (for those who don't know, go to Plugin System > Download/Upload Plugin > Browse for the file and upload it). Then, you simply upload the imageresize.php file into your main forum folder.
Instructions:
To place the user's avatar in the template, edit one of your vbtemplates (header template preferrably), and then insert this code where you want the image to appear:
$useravatar
If you want their avatar to link to their profile insert:<a href="$vboptions[bburl]/profile.php?do=editavatar">$useravatar</a>
To change the max height and width dimentions for the avatar, edit the plugin and change the following line of code:
//SET MAX RESTRAINTS
$maxheight=40;
$maxwidth=50;
Note: Upload both photoresize.php and noavatar.gif to your forum HOME directory. You can change the noavatar.gif image to whatever you want. Make sure you have your vbulletin homepage url set in your general vbulletin options area otherwise the script wont know the url of your forum!
Credits:
The "Avatar in Navbar" plugin by sabret00the [click here (https://vborg.vbsupport.ru/showthread.php?t=99498)]
NPL Solution's script from Webmaster-Talk [click here (http://www.webmaster-talk.com/php-forum/46469-dynamic-image-resizing.html)]
DONT FORGET TO CLICK INSTALL! :cool:
toolblast
04-18-2006, 04:03 AM
The FILE HAS BEEN UPDATED April 18th.
It is now easier to edit the constraints proportions, they are 2 variables at the very top of the plugin code that you can easily edit via the plugin manager.
Supports pre-defined avatars from your vbulletin collection, custom uploaded avatars, as well as can put an image in place of an avatar if the user has not yet specified one.
UPDATE: Two new screenshots added.
UPDATE: Support for both IE and FIREFOX added.
Kihon Kata
04-18-2006, 06:15 AM
woot, I'll check this out very soon
First post!
G-Force 199
04-18-2006, 02:11 PM
Installed.
But could you zip all the files ? Thank anyway.
The Chief
04-18-2006, 02:19 PM
this looks good, I will maybe try it out today :)
Kihon Kata
04-18-2006, 02:58 PM
COOL! INSTALLED! One problem, it didn't work! ;)
I installed this and all it did was put the text "Your Avatar" with a link to http://www.YOURSITENAME.com/forums/profile.php?do=editavatar
I tried to put it in a few different templates also.
toolblast
04-18-2006, 11:19 PM
Hi Kihon and others! Thanks for installing and testing.
I quickly uploaded this plugin last night as I finally got it working on my forum. However, there are a few bugs in the code which I am fixing right now.
Expect an updated zip file within an hour or so! Thanks.
toolblast
04-19-2006, 01:22 AM
Installed.
But could you zip all the files ? Thank anyway.
Zipped. Done.
toolblast
04-19-2006, 01:24 AM
COOL! INSTALLED! One problem, it didn't work! ;)
I installed this and all it did was put the text "Your Avatar" with a link to http://www.YOURSITENAME.com/forums/profile.php?do=editavatar
I tried to put it in a few different templates also.
It is showing 'yoursitename' and the avatar image is not working because you have not defined your website URL in your general Vbulletin settings. Do that and it should work fine.
Kihon Kata
04-19-2006, 01:40 AM
It is showing 'yoursitename' and the avatar image is not working because you have not defined your website URL in your general Vbulletin settings. Do that and it should work fine.
HI Tool! Uhm do you mean my "Internal URLs"?
And did you update it?
toolblast
04-19-2006, 01:42 AM
HI Tool! Uhm do you mean my "Internal URLs"?
The script uses the variable you have set in your vbulletin settings.
Go to your vbulletin admincp and tell me what you find here:
VBULLETIN OPTIONS > VBULLETIN OPTIONS > SITE NAME / URL / CONTACT DETAILS >> The variable called "FORUM URL" (2nd input box).
You should have the url to your forum in there with no trailing slash.
Kihon Kata
04-19-2006, 01:44 AM
I have that filled up with "http://www.MYSITENAME.com/forums" with no quotes and my real forum name.
toolblast
04-19-2006, 01:47 AM
Ok, and tell me:
1) Try putting the avatar code into the header template of your forum.
2) Then, login to your forum and make sure you have an avatar selected for the username you logged in with.
3) Make sure you've downloaded and are using the recent files I put in the zip file attached here.
It should work fine if you're using VB3.5. There must be a setting somewhere that is not set correctly on your forum if it doesnt work. I can show you a demo forum with this running if you'd like.
Kihon Kata
04-19-2006, 01:51 AM
I did the top 2 already. Did you update #3 today?
EDIT: I am using 3.5.4
toolblast
04-19-2006, 01:51 AM
Hi Kihon,
I just did some checking and I see the problem you are seeing now. It only seems to happen in FireFox. If you use IE the plugin works fine.
I wonder why it doesnt work in firefox. I'll look into it.
toolblast
04-19-2006, 01:52 AM
I did the top 2 already. Did you update #3 today?
EDIT: I am using 3.5.4
Yes. I just uploaded a new zip file. It seems that the image isnt displaying in firefox (though its common php thats creating the image, so Im not sure sure why).
Kihon Kata
04-19-2006, 01:55 AM
Oh ok, even though I have a busy forum with 99.99% women, many many use Firefox. I'll wait until you update it w/ firefox. :-)
toolblast
04-19-2006, 01:57 AM
Hi Kihon.
Ok, I have gotten it to work with FireFox now. I will upload a new zip file to this thread in about 4 minutes and it will be called 'PluginFiles.zip' ok?
Kihon Kata
04-19-2006, 02:04 AM
woot! nice support toolblast! update the version and I'll reinstall it
toolblast
04-19-2006, 02:18 AM
Ok Kihon. It should be all done.
Works in both Firefox and IE6. Ive checked both. Also, i've included an image called 'noavatar.jpg' which will show up if the user has no avatar.
Tell me if you have any problems!
toolblast
04-19-2006, 02:25 AM
Don't forget, the variable is now '$useravatar' if you just downloaded the latest zip file (which I uploaded a second ago). Then $useravatar is the variable you can use in any template to show your resized avatar of the current logged in user.
Kihon Kata
04-19-2006, 04:20 AM
Don't forget, the variable is now '$useravatar' if you just downloaded the latest zip file (which I uploaded a second ago). Then $useravatar is the variable you can use in any template to show your resized avatar of the current logged in user.
I'll try this in a few and report back soon, but what if I already use the "no avatar selected" hack?
Kihon Kata
04-19-2006, 04:36 AM
I'll try this in a few and report back soon, but what if I already use the "no avatar selected" hack? Ok, this STILL isn't working for me.
I uploaded the php file into the forum root, imported the plugin in the acp and I than went to my header template and addedd:
<a href="$vboptions[bburl]/profile.php?do=editavatar">$useravatar
</a>
I also try to add just "$useravatar"Internet Explorer is showing a RED X as my avatar and Firefox shows nothing
WHo knows.
toolblast
04-19-2006, 04:53 AM
Ok, right-click on the red x'd image and look at the properties of the image. Copy and paste that into this thread. Thanks :)
As for the 'no avatar image' hack, I'm not sure exactly what will happen because I dont have it installed on my test board. I would assume that the no avatar image hack either a) gives all users a default avatar, so they have an avatar at all times, just the one they get is your default one. This case, this plugin would just shrink and display the default avatar. b) it dynamically places a 'noavatar' image everywhere that the user's avatar is displayed and dynamically does it. Thus, the user sees 'do not use avatar' checked off in their usercp, but it shows the default image anyways. In this case Im not sure what would happen.
Is the 'no avatar image' hack, that is separate to this one, a plugin? If so, try turning that plugin off and seeing if this one works.
Kihon Kata
04-19-2006, 05:04 AM
RED X url:
http://www.MYSITEHERE.com/forums/imageresize.php?image_name=http://www.MYSITEHERE.com/forums/image.php?u=4&dateline=1139443346&image_height=40&image_width=50
yes, the default avatar is a plugin
toolblast
04-19-2006, 05:50 PM
Check with your host, you might not have the GD graphics library enabled on your server. Maybe if you want i'll put together a php file that will do a test to see if you have the requirements that php needs to generate the thumbnail.
Kihon Kata
04-19-2006, 08:21 PM
Check with your host, you might not have the GD graphics library enabled on your server. Maybe if you want i'll put together a php file that will do a test to see if you have the requirements that php needs to generate the thumbnail.
lol, I am my own host LOL. I run my own decidated webserver in a datacenter in NYC.
Running Linux Fedora ...this server also has GD 2 installed
toolblast
04-19-2006, 09:43 PM
Hmm. Well Kihon, I really dont know what to say lol. If you're running vb 3.5.4 and you're logged in as a user who has uploaded a custom avatar, and you are still seeing an X or nothing in firefox, then something is setup incorrectly on your server or your vbulletin forum.
If you'd like i'll PM you the URL to a test board I have running the plugin with nothing else installed and it works just fine.
Have you tried taking off the 'default avatar' hack you had installed?
Kihon Kata
04-19-2006, 10:24 PM
Yep, running a pretty successfull 3.5.4 with almost 400,000 posts :)
What if I let you come in as an admin and you can fool with it? PM me if interested
cannabis-world
04-24-2006, 02:21 AM
hi toolblast, do you know how I might use the imageresize.php to remove exif data from attachments as they are uploaded. I was told that if I can reduce the uploaded files color depth that it would remove the exif data. I was also told that if I resize it was also remove exif data, but I don't really want to resize attachments.
thanks for your time
toolblast
04-24-2006, 04:02 AM
Hi Cannabis,
Why do you need exif data removed, may I ask? There may be another solution.
cannabis-world
04-24-2006, 11:00 PM
the users have specifically requested that exif data get dropped for their personal security (cannabis gardeners), also it will help reduce the bandwidth, overhead etc.
thank you for looking into this matter, much appreciated!!
toolblast
04-25-2006, 01:24 AM
The only way I see that being done would be to recreate the image (thus taking away the tags from the previous authorship). Using this script you could do that. All you need to do is use the imageresize.php script and make the maximum dimentions HUGE like 99999. That way the image they do upload will not need to be resized. Once you've done that, php will recreate the image and it wont lose any quality (at least it shouldnt). Tell me how that goes. Goodluck.
fneumeier
04-25-2006, 03:13 AM
My original question was: Where in the code is the place to do this. And, hey, I really want to reduce the size of the images!
Any idea where in the code ist the place to do this? I just couldn't find the place where the images are being handled when/after uploaded by the user.
Thanks!
Franz
cannabis-world
04-27-2006, 01:42 PM
I'm kinda in the same boat, due to my lack of php skills I'm not sure where to put the include, but I figured out it would go in the includes/class_upload.php somewhere
yellowchaser
04-27-2006, 04:20 PM
How can this be used in the postbit so that all users avatars can be made a consistent size within the forums? What code and where would need to be replaced to make this work? I would assume the post_bit but not sure.
toolblast
04-27-2006, 06:48 PM
My original question was: Where in the code is the place to do this. And, hey, I really want to reduce the size of the images!
Any idea where in the code ist the place to do this? I just couldn't find the place where the images are being handled when/after uploaded by the user.
Thanks!
Franz
What are you wanting to resize... ALL images that your users upload in their forum posts? So, it would be in the postbit where the forum displays the images attached to the post?
I'm kinda in the same boat, due to my lack of php skills I'm not sure where to put the include, but I figured out it would go in the includes/class_upload.php somewhere
Im not exactly sure what you are doing here, what are you putting the include code in your upload script? This script dynamically resizes the images on OUTPUT, not when saving the image. So, the image that is uploaded by the user is uploaded normally, this script would kick in where that uploaded image is meant to be DISPLAYED, the script would take the original uploaded image, resize it, and then output the new one all in realtime without saving a new jpg file.
toolblast
04-27-2006, 06:52 PM
How can this be used in the postbit so that all users avatars can be made a consistent size within the forums? What code and where would need to be replaced to make this work? I would assume the post_bit but not sure.
You will need to go into the postbit template via the VBulletin AdminCP template editor. Once you're in the postbit template (postbit templates > postbit), find where it outputs the user's avatar:
<if condition="$show['avatar']"> <br /><a href="member.php?$session[sessionurl]u=$post[userid]"><img src="$post[avatarurl]" alt="<phrase 1=" $post[username]">$vbphrase[xs_avatar]</phrase>" border="0" /></a></if>
And replace it with:
<if condition="$show['avatar']"> <br /><a href="member.php?$session[sessionurl]u=$post[userid]">$useravatar</a></if>
P.S. And thanks rmxs for the thank-you ;)
fneumeier
04-28-2006, 03:20 AM
What are you wanting to resize... ALL images that your users upload in their forum posts? So, it would be in the postbit where the forum displays the images attached to the post?
Chad,
I've read such suggestions now many time here in various forums. But this definitely it not a solution but only is a desaster for performance on my server. Imaging users upload a 3-Mpixel image and VB is resizing this EVERY TIME this image is being viewed! Also, think about storage space these pictures would need on the server/in the database!
No, I really want to resize the images right when they're uploaded. In consider this as extremely userfriendly (no need fo the user to resize the images prior to upload) and as a optimal solutions for server performance and storage space. The high resolution/big sized images are not needed for anything, so why keep them on the server?
Have you got an idea where to resize the pictures right at the upload?
Thanks
Franz
toolblast
04-28-2006, 05:31 PM
Chad,
I've read such suggestions now many time here in various forums. But this definitely it not a solution but only is a desaster for performance on my server. Imaging users upload a 3-Mpixel image and VB is resizing this EVERY TIME this image is being viewed! Also, think about storage space these pictures would need on the server/in the database!
No, I really want to resize the images right when they're uploaded. In consider this as extremely userfriendly (no need fo the user to resize the images prior to upload) and as a optimal solutions for server performance and storage space. The high resolution/big sized images are not needed for anything, so why keep them on the server?
Have you got an idea where to resize the pictures right at the upload?
Thanks
Franz
Clearly you would need to restrict file size for image uploads so users cant upload unlimited 3MP images. Thats pretty obvious.
This script does dynamic resizing like the title of this thread states. It isn't a script that resizes and then resaves the image, overwriting the original. Though, im sure you could find a php script that does that by searching Google.
Thanks.
fneumeier
04-28-2006, 07:21 PM
My posting probably was not clear enough: I know HOW to resize a image with PHP and GDlib. I just don't find the place in the VB code WHERE to pick up the image date after upload and manipulate it. Any hints where in the code I have to look for that? I suppose it's in the class_upload, but I can't find the exact position ...
Thanks
Franz
toolblast
04-29-2006, 02:49 AM
I really dont know where it is, I'd have to go hunting.
Does any expert vb coder know where this bit of code is?
cannabis-world
04-29-2006, 12:07 PM
I know that vb strips the exif data when it makes thumbnails, so is it possible to resize the attachments as they are being uploaded to say 99% of their original size, thereby stripping the exif data. Perhaps someone reading this can help. Thanks for your help toolblast but unfortunately resizing on the fly will slow down our server considerably.
SQL man
05-01-2006, 12:35 AM
hi , I tried to test it
it didn't work with my member's avatar in the threads pages !! it still big images!!
whats the problem ?
cucarot
05-06-2006, 10:42 PM
how to use it in postbit ^ ^ I mean how to resize avatar of a user in postbit if he/she uploads an avatar that exceeds the limit of forum? :) thx
toolblast
05-12-2006, 12:39 PM
hi , I tried to test it
it didn't work with my member's avatar in the threads pages !! it still big images!!
whats the problem ?
Can you give me a demo/test URL to see this SQL man? Or if you feel comfortable enough grant me admincp access and I'll see whats wrong. Previous users have PMd me to get me to install this for them and I have been able to get it working for them.
toolblast
05-12-2006, 01:13 PM
how to use it in postbit ^ ^ I mean how to resize avatar of a user in postbit if he/she uploads an avatar that exceeds the limit of forum? :) thx
Hi Cucarot!
Right now I had to fix a few bugs and this plugin now only works in the forum header and navbar (and a few other templates). Unfortunately it doesnt work in the postbit template (it just shows a blank space instead of the avatar).
I am working on a new version of this plugin that will allow admins to easily add restraints to ANY image attachments/uploads which has been a huge request here on vb.org and I'll keep everyone updated, so stay tooned!
Thanks
The Chief
05-16-2006, 07:49 PM
Can you get this to work without Apache? (without GD Library installed)
The Chief
05-17-2006, 03:09 AM
Can anybody get this to work with ImageMagick??
toolblast
05-17-2006, 03:11 PM
Hi Chief! Nice to see you here.
I believe it is only coded to work with GD right now but I'll look for php code that may work with imagemagick
-------------
Just a note to everyone who hasn't realized that I updated the plugin description: this hack doesn't work EVERYWHERE like previously stated. Some templates in vbulletin do not render global variables making the plugin not show the avatar. One of these templates is the postbit template. If you put '$useravatar' in that template nothing will happen. Why? I'm not sure, and if anyone knows how to make it work please share!
Thanks.
toolblast
05-17-2006, 03:13 PM
Hey Chief,
I think I found something that may help. I haven't examined the code yet, but this page looks promising:
http://www.imagemagick.org/script/convert.php
The Chief
05-17-2006, 06:19 PM
Hey Chief,
I think I found something that may help. I haven't examined the code yet, but this page looks promising:
http://www.imagemagick.org/script/convert.php
Yup, it does, this is what I would need, if you can get this to work with a different plug-in or the same one you would make one more happy man ;)
Tell me if you need help testing it.
toolblast
05-18-2006, 12:43 PM
Hmm. Well it looks like it would require a lot of research and coding to get imagemagick working lol. There really isn't very much documentation on the resizing function in IM with PHP.
Maybe in the future I'll try and add that in. In the meantime, you need to get GD Library on your server! lol
The Chief
05-18-2006, 03:40 PM
Hmm. Well it looks like it would require a lot of research and coding to get imagemagick working lol. There really isn't very much documentation on the resizing function in IM with PHP.
Maybe in the future I'll try and add that in. In the meantime, you need to get GD Library on your server! lol
That's something I can't do. Apache is uninstalled on my server, I am running my website on lighttpd which means no Apache, and why couldn't it be possible? vB 2.~something uses ImageMagick and there is some hacks for automatically resizing user avatars, but I only need it for this ;)
futuredood
08-02-2006, 04:00 AM
hey toolblast,
have you made any progress in how to get the postbit_legacy to resize the image? this is similar to what i've been trying to do. i'm trying to have the profile pic in the memberinfo template, and in postbit_legacy to automatically resize that into an avatar. this would make the profilepic and avatar the same image. i have a whole thread going on on it here:
https://vborg.vbsupport.ru/showthread.php?t=122710
bashy
03-18-2007, 08:31 AM
i tried this on 3.6 but no go for launch :(
Any chance on an upgrade please? :)
v12kid
04-18-2007, 11:33 PM
same question, can you port this for 3.6 Ill even pay you for it! lol
Tralala
04-22-2007, 10:16 PM
No go on 3.6.5 here either... would love to see an update!
rsuplido
12-13-2007, 08:57 AM
Attached is a new imageresize.php script that should work with 3.6.5. Overwrite the original one. This script came from http://tech.mikelopez.info/2006/03/02/php-image-resize-script/ modified to work with this mod.
HunteRRosE
01-27-2008, 05:28 AM
anyone get this to work on 3.6.8?
nando99
05-20-2008, 06:56 PM
I know this is old - but I'd love to see this for 3.6.8
Mischievious
06-14-2008, 10:36 PM
I'd like to see this ported over to 3.7.1. Too bad the original coder does not seem to support his work any longer.
Javierogo
10-28-2009, 05:11 AM
This %$/&#$ does not work :down:
danyxxx
09-13-2011, 07:17 AM
For 3.8.6 ?
Can this be made?
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.