Mantis Bug Tracker
 

View Issue Details Jump to Notes ] Wiki ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0008257mantisbtfeaturepublic2007-08-11 14:192010-06-30 00:58
Reportermkornatzki 
Assigned To 
PrioritynormalSeverityminorReproducibilityN/A
StatusacknowledgedResolutionopen 
PlatformOSOS Version
Product Version1.1.0a4 
Target VersionFixed in Version 
Summary0008257: store avatar local
DescriptionHi,

i like the avatar-feature but for me it is neccessary to store the files local and give the user the possibility to handle their avatar.

for this i made a patch:
* you can see in the user_list which user has an avatar (with picture or as boolean)
* the user can upload or delete his avatar
* if a user didn't have an avatar there is no default image

if you want to use this patch you have to add a directory "/avatar".

this is the first try and i hope someone of you will make it better (errorhandling, maybe performance, ...).

thanks for the integration of avatars in mantis.
Mike
TagsNo tags attached.
Attached Filespatch file icon add_local_avatar.patch [^] (10,285 bytes) 2007-08-11 14:19 [Show Content]
gif file icon edit_user.gif [^] (9,350 bytes) 2007-08-11 14:20


gif file icon manage_user_list.gif [^] (10,593 bytes) 2007-08-11 14:21


gif file icon gmail_contact_data.gif [^] (15,910 bytes) 2007-08-11 17:06


patch file icon local_avatar_cvs.patch [^] (16,548 bytes) 2007-08-12 08:46 [Show Content]
gif file icon edit_account.gif [^] (13,953 bytes) 2007-08-12 08:49


patch file icon local_avatar_cvs_2.patch [^] (18,623 bytes) 2007-08-14 16:26 [Show Content]
patch file icon local_avatar.patch [^] (13,966 bytes) 2008-05-31 08:51 [Show Content]
diff file icon file_avatar_mthibeault.diff [^] (21,649 bytes) 2008-12-01 12:09 [Show Content]
diff file icon local_avatar_another_take.diff [^] (15,693 bytes) 2009-03-29 04:40 [Show Content]
? file icon local_avatar_another_take.sql [^] (747 bytes) 2009-03-29 04:49
diff file icon local_avatar_1.2.x.diff [^] (35,983 bytes) 2009-04-11 20:21 [Show Content]
patch file icon 0001-Loacal-avatar.patch [^] (41,850 bytes) 2009-04-16 00:54 [Show Content]

- Relationships

-  Notes
User avatar (0015420)
giallu (developer)
2007-08-11 17:04

I would be glad to integrate your modifications into mantis, but before there are some issues I would like to see addressed: are you willing to help?

At a first glance:

* the patch should be done against the latest release, or even better CVS HEAD. More info on this in: http://www.mantisbt.org/wiki/doku.php/mantisbt:howto_submit_patches [^]

* you should use tabs for indentation

* IMHO the constrain on size should be instead on dimensions (width, height), 80x80 being a reasonable default

* When the uploaded avatar is bigger than the preference, it should be resized to fit before saving on disk

* the path for storing the avatar should be a configuration option

* AFAICT, you are not using anymore the gravatars. I think we should let the user decide if he wants to use the local one or the gravatar one: I am going to attach a sample of what I have in mind.
User avatar (0015423)
mkornatzki (reporter)
2007-08-12 08:44

shure i will help if i can.

i made a patch against the cvs head.

now a user can confige the avatar in the account_page. you can decide if your image come from gravatar or form an uploaded file.
an administrator can also do the configuration in the manage_user_edit_page.

* i used tabs
* sorry i didn't do the resize on storing the file, because than i had to use a graphic-library (if that's not true you can mybe show me the way)
* the image will be resized to fit $g_avatar_max_width and $g_avatar_max_height
* the path is now stored in $g_directory_avatar
User avatar (0015425)
giallu (developer)
2007-08-12 11:28

Much better :)

About the resize, the same library you are using when you call getimagesize() should be able to do the trick; please check:

http://www.php.net/imagecopyresampled [^]
and/or
http://www.php.net/imagecopyresized [^]
User avatar (0015427)
DGtlRift (developer)
2007-08-12 16:52

The patch should also allow for storing the image in the database or ftp server rather just to the local filesystem. See core/file_api.php
User avatar (0015428)
giallu (developer)
2007-08-12 17:26

Victor asked me explicitly to not involve the DB at this stage.

I liked the DB solution because some more work will be required if I decide to activate the feature in the Fedora RPM, but this way the implementation look simpler
User avatar (0015435)
mkornatzki (reporter)
2007-08-14 16:25

thank you for your advise.

it is now possible to configure ($g_resize_avatar_on_store) if the file should resize on store (default OFF).

the function for store and delete is in filter.api
User avatar (0015931)
pluntke (reporter)
2007-10-21 11:59

I would also like the local avatar solution, as I'm not very happy of the possibility to store every step I do in the web at gravatar (they get asked for a gravatar for my email, so even when I don't have one, they could track where my email/avatar request comes from - right?)
User avatar (0015939)
vboctor (administrator)
2007-10-21 19:37

Looks like we are doing good work here. It would be great if you can create some functional description of what we are doing here in the Wiki. You can use the Wiki page associated with this issue. This will allow me (since I am not involved with the details of the patches) and others to look at it and provide feedback. The snapshots done so far will help :)

The wiki page should include:

1. What are we trying to achive?
2. Why?
3. What are the admins options?
4. What are the users options?
5. Where do we store local avatars?
6. Configuration Changes
7. Database changes

Thanks a lot and keep up the good work.
User avatar (0015978)
giallu (developer)
2007-10-25 08:29

Victor, despite being a time consuming task, I'd love to use the associated wiki page but... 0008110
User avatar (0016714)
pluntke (reporter)
2008-01-18 07:40

which version is the latest patch for?
has anyone tested with 1.1.0 of mantis?
will it be implemented?
I would really like it
User avatar (0016903)
cheater (reporter)
2008-02-01 03:47

There´s one bigger issue:
In the file /core/file_api.php
function: file_avatar_upload
you use the header-function "header('Content-type: ..."
This isn´t useful, because the script stops after saving the local avatar, because the browser gets the following output as an image.
After deleting this, the scripts works fine in 1.1.1

One small issues:
- The UTF-8 Strings in lang/strings_german.txt aren´t corret (german Umlaute)
User avatar (0017190)
rady (reporter)
2008-02-25 03:33

Hi first of all. I'm interested in adding this patch to my mantis bug tracker, but i'm still very new to this, and i don't think i figured the way it is done. Can anyone help me out?

Thanks in advance!
User avatar (0017301)
mkornatzki (reporter)
2008-03-09 10:42

If i use the avatar-feature with a https-connection i get the following error "[function.getimagesize]: failed to open stream: Invalid argument"

You can fix the error if you change the following function in user.api

    function user_get_local_avatar( $p_user_id ) {
        global $g_path;
        $t_avatar_exist = true;
        $avatar_dir = config_get('directory_avatar');
        $t_avatar_local_path = dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . $avatar_dir . DIRECTORY_SEPARATOR;
    
    # default imagesize
    $t_height = config_get('avatar_max_height');
    $t_width = config_get('avatar_max_width');

        # if the variable $g_show_realname is on then user_get_name returns the realname.
        #$t_username = user_get_name( $p_user_id );
        #$t_row = user_cache_row( $p_user_id, false );
        #$t_username = $t_row['username'];
    $t_username = user_get_field($p_user_id, 'username');

        $t_avatar_local = $t_avatar_local_path . $t_username . '.gif';
        $t_avatar_url = $g_path . $avatar_dir . '/' . $t_username . '.gif';
    if (!file_exists($t_avatar_local)) {
      $t_avatar_local = $t_avatar_local_path . $t_username . '.jpg';
            $t_avatar_url = $g_path . $avatar_dir . '/' . $t_username . '.jpg';
      if (!file_exists($t_avatar_local)) {
        $t_avatar_exist = false;
      }
    }

    if ($t_avatar_exist) {
      # get image dimensions
      list($width_orig, $height_orig) = getimagesize($t_avatar_local);
...

Maybe someone can find a better solution.
User avatar (0017971)
mkornatzki (reporter)
2008-05-31 08:53

Hi, i have made a patch (local_avatar.patch) against the actual trunk.

You have to crate a new Folder "avatar" to store the local images.
User avatar (0020174)
mthibeault (reporter)
2008-12-01 12:16

Added a patch against the latest GIT. It has been in production environment for a couple months now. Added some resizing features and it is able to use ImageMagick if present (or rely on GD like the original one).
There is still only one issue where the user needs to reload the avatar before seeing the new one after changing it because I am using a single name for the file to prevent users from flooding the server with images.
The images are also resized (proportionally) to the necessary size to take less space on the server (or just more constant space with about 20-25k per avatar).
User avatar (0021259)
bartik (reporter)
2009-03-29 04:48
edited on: 2009-03-29 04:50

I have added another take on the local avatar. It uses the existing file_api.php to store the avatar (new table is added) that means you can use the database, ftp or disk. It uses file_download.php to actually show the picture. It will try to find the local avatar first if enabled and then it falls back to gravatar. The file_api.php got a small overhaul in the process. I have tested this only with the database storage. There is no image resizing. And you have to add the following variables to the config_inc.php :

$g_mantis_avatar_file_table = '%db_table_prefix%_avatar_file%db_table_suffix%';
$g_avatar_files_prefix = 'avatar';
$g_avatar_type = 'local';

and the changes are made for the english language only. Thanks for your effort.
And the diff is agains the 1.1.6 branch HEAD as of posting of this note.

User avatar (0021406)
giallu (developer)
2009-04-06 16:59

bartik, I definitely want to move on here, but we need to work on the git master branch, we can't add stuff to 1.1.6.

So, if any of is interested to help, what we need is one (or more) patches to apply on top of git master.

If some cleanup of file API can be done in the meanwhile, good; anyway, please try to provide it in a separate patchset (just store them ion your local branch, then "git format-patch" will be your friend)

thanks a lot
User avatar (0021475)
bartik (reporter)
2009-04-11 20:21

I have attached the diff against the 1.2.x branch (I have a checkout from 7.4.2009 22:12) The added mantis_avatar_file_table is the same as for 1.1.6 I'm sorry but the file_api.php cleanup is also part of this diff and not a separate patch. I did some testing but a more detailed test would be in order. I have to get more familiar with git in the meantime perhaps. Thanks.
User avatar (0021527)
giallu (developer)
2009-04-14 11:24

bartik. thanks a lot.
I will retry to apply your patch and see if I can commit it as is, or be back at you with some more comments.
User avatar (0021567)
giallu (developer)
2009-04-15 17:54

bartik, is it possible you forgot to add to your patch the new file:
account_prefs_avatar_upload_inc.php
?
User avatar (0021568)
bartik (reporter)
2009-04-16 00:56

Yes that is entirely possible given my relationship with git. I have now generated a patch which should contain also the missing files. I hope it works now. Thanks.
User avatar (0021569)
giallu (developer)
2009-04-16 02:47

eh eh, like in any other relationships, it takes time to really know each other ;)
User avatar (0024858)
borrmann (reporter)
2010-03-23 06:12

Hey
has someone a patch / diff for the current release 1.2.0?
User avatar (0025998)
djcarr (reporter)
2010-06-30 00:58
edited on: 2010-07-14 22:07

I'm keen to see this feature too, because it allows admins and managers to set up avatars for users.

Also, I've found that with some Mantis users in China that they cannot retrieve the gravatars (probably due to firewalls) and the page takes forever to load.

Would it be suited to a plugin? I think it just needs two hook-in points (1) on the Edit User page and (2) in the avatar retrieval.


- Issue History
Date Modified Username Field Change
2007-08-11 14:19 mkornatzki New Issue
2007-08-11 14:19 mkornatzki File Added: add_local_avatar.patch
2007-08-11 14:20 mkornatzki File Added: edit_user.gif
2007-08-11 14:21 mkornatzki File Added: manage_user_list.gif
2007-08-11 17:04 giallu Note Added: 0015420
2007-08-11 17:06 giallu File Added: gmail_contact_data.gif
2007-08-12 08:44 mkornatzki Note Added: 0015423
2007-08-12 08:46 mkornatzki File Added: local_avatar_cvs.patch
2007-08-12 08:49 mkornatzki File Added: edit_account.gif
2007-08-12 11:28 giallu Note Added: 0015425
2007-08-12 16:52 DGtlRift Note Added: 0015427
2007-08-12 17:26 giallu Note Added: 0015428
2007-08-14 16:25 mkornatzki Note Added: 0015435
2007-08-14 16:26 mkornatzki File Added: local_avatar_cvs_2.patch
2007-10-21 11:59 pluntke Note Added: 0015931
2007-10-21 12:18 pluntke Issue Monitored: pluntke
2007-10-21 19:37 vboctor Note Added: 0015939
2007-10-25 08:29 giallu Note Added: 0015978
2008-01-18 07:40 pluntke Note Added: 0016714
2008-02-01 03:47 cheater Note Added: 0016903
2008-02-01 08:02 totten2 Issue Monitored: totten2
2008-02-25 03:33 rady Note Added: 0017190
2008-03-09 10:42 mkornatzki Note Added: 0017301
2008-05-31 08:51 mkornatzki File Added: local_avatar.patch
2008-05-31 08:53 mkornatzki Note Added: 0017971
2008-07-01 10:33 totten2 Issue End Monitor: totten2
2008-10-15 09:36 ghohm Issue Monitored: ghohm
2008-12-01 12:09 mthibeault File Added: file_avatar_mthibeault.diff
2008-12-01 12:16 mthibeault Note Added: 0020174
2008-12-01 12:16 mthibeault Issue Monitored: mthibeault
2008-12-01 17:04 stefang Issue Monitored: stefang
2008-12-10 08:14 Kirill Issue Monitored: Kirill
2008-12-20 19:48 grangeway Status new => acknowledged
2009-03-29 04:40 bartik File Added: local_avatar_another_take.diff
2009-03-29 04:48 bartik Note Added: 0021259
2009-03-29 04:49 bartik File Added: local_avatar_another_take.sql
2009-03-29 04:50 bartik Note Edited: 0021259
2009-04-06 16:59 giallu Note Added: 0021406
2009-04-11 20:21 bartik Note Added: 0021475
2009-04-11 20:21 bartik File Added: local_avatar_1.2.x.diff
2009-04-14 11:24 giallu Note Added: 0021527
2009-04-15 17:54 giallu Note Added: 0021567
2009-04-16 00:54 bartik File Added: 0001-Loacal-avatar.patch
2009-04-16 00:56 bartik Note Added: 0021568
2009-04-16 02:47 giallu Note Added: 0021569
2009-05-27 13:13 stb Issue Monitored: stb
2009-12-30 04:47 piccolobill Issue Monitored: piccolobill
2010-03-23 06:12 borrmann Note Added: 0024858
2010-03-24 06:34 Phileas Issue Monitored: Phileas
2010-06-30 00:58 djcarr Note Added: 0025998
2010-06-30 00:59 djcarr Note Edited: 0025998 View Revisions
2010-07-14 22:06 djcarr Note Edited: 0025998 View Revisions
2010-07-14 22:07 djcarr Note Edited: 0025998 View Revisions
2010-07-14 22:07 djcarr Note Edited: 0025998 View Revisions


MantisBT 1.2.2 git master-1.2.x[^]
Copyright © 2000 - 2010 MantisBT Group
Time: 0.5160 seconds.
memory usage: 2,309 KB
Powered by Mantis Bugtracker