Module: User Avatar
Posted by Maurice Makaay
|
Re: Module: User Avatar November 14, 2008 09:28AM |
Registered: 19 years ago Posts: 10 |
|
Re: Module: User Avatar November 14, 2008 09:30AM |
Admin Registered: 23 years ago Posts: 9,240 |
|
Re: Module: User Avatar November 14, 2008 09:43AM |
Registered: 19 years ago Posts: 10 |
|
Re: Module: User Avatar November 16, 2008 12:38AM |
Registered: 17 years ago Posts: 27 |
Hey,
i want to use users avatar pictures on my index page,
[code="php"]
$query = mysql_query("SELECT * FROM phorum_files
WHERE link='avatar' AND user_id='$user_id'
LIMIT 1");
while ($r1 = mysql_fetch_array($query))
{
print("<img src=\"phorum/file.php?0,file=" . $r1['file_id'] . ",filename=" . $r1['filename'] . "\" />");
}
[/code]
i tried those codes, i cant see the image on page but i can see with right clicking - and "show image" option.
but i cant show the image on panel
thanks,
Edited 4 time(s). Last edit at 11/16/2008 02:04AM by jeem.
i want to use users avatar pictures on my index page,
[code="php"]
$query = mysql_query("SELECT * FROM phorum_files
WHERE link='avatar' AND user_id='$user_id'
LIMIT 1");
while ($r1 = mysql_fetch_array($query))
{
print("<img src=\"phorum/file.php?0,file=" . $r1['file_id'] . ",filename=" . $r1['filename'] . "\" />");
}
[/code]
i tried those codes, i cant see the image on page but i can see with right clicking - and "show image" option.
but i cant show the image on panel
thanks,
Edited 4 time(s). Last edit at 11/16/2008 02:04AM by jeem.
|
Re: Module: User Avatar November 16, 2008 05:55AM |
Admin Registered: 21 years ago Posts: 8,532 |
Check the setting "Allow Linking To Uploaded Files" from the "General Settings" section in the Phorum admin. If that is not set to "From any website", then check if setting it to that option changes things for you.
The code in general looks okay to me. You might want to use urlencode($r1['filename']) instead of plain $r1['filename'] to make sure that special characters are escaped correctly in the URL.
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
The code in general looks okay to me. You might want to use urlencode($r1['filename']) instead of plain $r1['filename'] to make sure that special characters are escaped correctly in the URL.
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
|
Re: Module: User Avatar November 16, 2008 06:09AM |
Registered: 17 years ago Posts: 27 |
|
Re: Module: User Avatar December 14, 2008 12:41PM |
Registered: 17 years ago Posts: 24 |
Is there any way that you could incorporate 'convert' into this for resizing? I currently have a home rolled hack/module that I use so users can upload their picture. I'm probably going to borrow a bit of code from this module so that they can upload more than 1 photo, delete old ones (Currently you can only upload a photo to remove the current one).
However my end users are not the brightest computer users and if I told them that their photo had to be such that the longest edge was 600px and had to be in a jpg format, I don't know if I'd ever get photos. Some guys tried uploading BMPs huge photos, etc.
My host has ImageMagick installed, so I use the convert program to scale images to 600 if they are larger. I was playing with this in the avatar module and it wouldn't be too hard to add. Just add a check box for "Resize" and then a box for a link to the convert binary. Then some logic, "If resize is enabled, do resize".
[code="php"]
$new_file = tempnam("/tmp/","upload_").".jpg";
$command = "/usr/bin/convert -thumbnail '600x600>'" . " '" . $_FILES['pict']['tmp_name'] . "' '" . $new_file . "'";
[/code]
However my end users are not the brightest computer users and if I told them that their photo had to be such that the longest edge was 600px and had to be in a jpg format, I don't know if I'd ever get photos. Some guys tried uploading BMPs huge photos, etc.
My host has ImageMagick installed, so I use the convert program to scale images to 600 if they are larger. I was playing with this in the avatar module and it wouldn't be too hard to add. Just add a check box for "Resize" and then a box for a link to the convert binary. Then some logic, "If resize is enabled, do resize".
[code="php"]
$new_file = tempnam("/tmp/","upload_").".jpg";
$command = "/usr/bin/convert -thumbnail '600x600>'" . " '" . $_FILES['pict']['tmp_name'] . "' '" . $new_file . "'";
[/code]
|
Re: Module: User Avatar December 14, 2008 12:56PM |
Admin Registered: 21 years ago Posts: 8,532 |
For creating thumnails, I started the image API in include/api/image.php, to have a generic image scaling library that can be used from any module that needs image processing. I'm planning on putting the resizing in the avatar module. Maybe even some extra nice tool like cropping, which is not too hard if the image processing backend tools are available on the server.
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
|
Re: Module: User Avatar January 30, 2009 02:49AM |
Registered: 17 years ago Posts: 6 |
I just upgrade my 5.2.9a phorum to 5.2.10 version. All is OK, but my mod Avatar don't work. In ../templates/emerald/read.tpl I add
<td style="padding-right:10px">
{IF MESSAGES->user_avatar}
<img src="{MESSAGES->user_avatar}" alt="avatar"
{IF MESSAGES->user_avatar_w}
style="width:{MESSAGES->user_avatar_w}px;
height:{MESSAGES->user_avatar_h}px"
{/IF} />
{/IF}
</td>
as it was in the old phorum.
Please, help me!
<td style="padding-right:10px">
{IF MESSAGES->user_avatar}
<img src="{MESSAGES->user_avatar}" alt="avatar"
{IF MESSAGES->user_avatar_w}
style="width:{MESSAGES->user_avatar_w}px;
height:{MESSAGES->user_avatar_h}px"
{/IF} />
{/IF}
</td>
as it was in the old phorum.
Please, help me!
|
Re: Module: User Avatar January 30, 2009 09:05AM |
Registered: 17 years ago Posts: 22 |
Sorry, only registered users may post in this forum.



