Changeset 568

Show
Ignore:
Timestamp:
08/07/07 17:00:01 (1 year ago)
Author:
louisedade
Message:

avatar-upload: committing version 0.8.2 - bug-fix and added class name to img tag

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • avatar-upload/trunk/bb-avatar-upload.php

    r532 r568  
    33Plugin Name: Avatar Upload 
    44Plugin URI: http://bbpress.org/plugins/topic/46 
    5 Version: 0.8.1 
     5Version: 0.8.2 
    66Description: Allows users to upload an avatar (gif, jpeg/jpg or png) image to bbPress. 
    77Author: Louise Dade 
     
    7474 
    7575// Display the avatar image 
    76 function avatarupload_display($id, $force_db=0
     76function avatarupload_display($id, $force_db=0, $class='avatar'
    7777{ 
    7878        if ($a = avatarupload_get_avatar($id,1,$force_db)) 
    7979        { 
    80                 echo '<img src="'.$a[0].'" width="'.$a[1].'" height="'.$a[2].'" alt="'.$a[4].'" />'; 
     80                echo '<img src="'.$a[0].'" width="'.$a[1].'" height="'.$a[2].'" alt="'.$a[4].'" class="'.$class.'" />'; 
    8181        } else { 
    8282                $config = new avatarupload_config(); 
     
    8686                        // Use a "genric" default avatar 
    8787                        echo '<img src="'.$config->default_avatar['uri'].'" width="'.$config->default_avatar['width'] 
    88                         .'" height="'.$config->default_avatar['height'].'" alt="'.$config->default_avatar['alt'].'" />'; 
     88                        .'" height="'.$config->default_avatar['height'].'" alt="'.$config->default_avatar['alt'].'" class="'.$class.'" />'; 
    8989                } else { 
    9090                        // Or use Identicons instead.  New users will have an identicon automatically 
     
    9696                        if ($a = avatarupload_get_avatar($id,1,$force_db)) 
    9797                        { 
    98                                 echo '<img src="'.$a[0].'" width="'.$a[1].'" height="'.$a[2].'" alt="'.$a[4].'" />'; 
     98                                echo '<img src="'.$a[0].'" width="'.$a[1].'" height="'.$a[2].'" alt="'.$a[4].'" class="'.$class.'" />'; 
    9999                        } 
    100100                } 
     
    110110        $cached = bb_get_user($id); 
    111111 
    112         if ($force_db == 0 && (!empty($user) || !empty($cached)) ) 
    113         { 
    114                 if (!empty($user->avatar_file)) { 
    115                         $a = explode("|", $user->avatar_file); 
    116                         $a[] = $user->user_login; // for 'alt' attribute 
    117                 } else { 
    118                         if (!empty($cached)) { 
    119                                 $a = explode("|", $cached->avatar_file); 
    120                                 $a[] = $cached->user_login; // for 'alt' attribute 
    121                         } else { 
    122                                 return false; 
    123                         } 
    124                 } 
    125         } 
    126         else 
     112        // if $user-avatar-file and $cached->avatar_file are both empty, 
     113        // or we want to force the db query. 
     114        if ((empty($user->avatar_file) && empty($cached->avatar_file)) || $force_db == 1) 
    127115        { 
    128116                $bb_query = "SELECT meta_value FROM $bbdb->usermeta WHERE meta_key='avatar_file' AND user_id='$id' LIMIT 1"; 
     
    134122                        return false; 
    135123                } 
    136         } 
    137          
     124        } else { 
     125                if (!empty($user->avatar_file)) { 
     126                        $a = explode("|", $user->avatar_file); 
     127                        $a[] = $user->user_login; // for 'alt' attribute 
     128                } elseif (!empty($cached->avatar_file)) { 
     129                        $a = explode("|", $cached->avatar_file); 
     130                        $a[] = $cached->user_login; // for 'alt' attribute 
     131                } else { 
     132                        return false; 
     133                } 
     134        } 
     135 
    138136        // do we want the full uri? 
    139137        if ($fulluri == 1) 
     
    156154} 
    157155add_action( 'bb_profile_menu', 'add_avatar_tab' ); 
    158  
    159156 
    160157//  bbPress Identicon function by Fel64 
  • avatar-upload/trunk/readme.txt

    r532 r568  
    44Requires at least: 0.8.2 
    55Tested up to: 0.8.2.1 
    6 Stable Tag: 0.8.1 
     6Stable Tag: 0.8.2 
    77 
    88Allows users to upload an avatar (gif, jpeg/jpg or png) image to bbPress. Admins can configure maximum allowed file size and image dimensions. Includes fel64's code enabling 'Identicons' - default avatars made of abstract patterns unique to each user. 
     
    3838== Installation == 
    3939 
     40IMPORTANT: If the `avatars/` and `my-templates/` folders (in `additional-files/`) are empty in the ZIP archive, please download the files directly from the SVN trunk: 
     41 
     42* http://plugins-dev.bbpress.org/browser/avatar-upload/trunk/additional-files/avatars/default.png 
     43 
     44* http://plugins-dev.bbpress.org/browser/avatar-upload/trunk/additional-files/my-templates/avatar.php 
     45 
     46For each file above, scroll to the bottom of the page, where it says "Download in other formats" and click on the "Original format" link. 
     47 
    4048UPGRADING?  If you are using a version older than 0.3 of this plugin you NEED to follow these instructions fully because the template functions are incompatible with older versions.  If you are upgrading from version 0.3 or later then of this plugin you can ignore the template instructions (steps 2 to 4), but do check the rest. 
    4149 
     
    6775 
    6876     Where ID is a user ID. Returns false if no avatar exists for that user. 
     77 
     78  d) The `<IMG>` tag that displays the avatar uses the class name 'avatar' to use in your CSS file. 
    6979 
    70804. OPTIONAL: open up `my-templates/avatar.php` and edit the template if you wish, but be sure not to mess with the upload form. 
     
    133143 
    134144== Change Log == 
     1452007-08-07 Ver. 0.8.2 Bug-fix (default avatars not displaying). Added a classname ('avatar') to img tag. 
     146 
    1351472007-08-02 Ver. 0.8.1 Bug-fix, plus improved cache support that should have been in previous update. 
    136148