Changeset 568
- Timestamp:
- 08/07/07 17:00:01 (1 year ago)
- Files:
-
- avatar-upload/trunk/bb-avatar-upload.php (modified) (7 diffs)
- avatar-upload/trunk/readme.txt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
avatar-upload/trunk/bb-avatar-upload.php
r532 r568 3 3 Plugin Name: Avatar Upload 4 4 Plugin URI: http://bbpress.org/plugins/topic/46 5 Version: 0.8. 15 Version: 0.8.2 6 6 Description: Allows users to upload an avatar (gif, jpeg/jpg or png) image to bbPress. 7 7 Author: Louise Dade … … 74 74 75 75 // Display the avatar image 76 function avatarupload_display($id, $force_db=0 )76 function avatarupload_display($id, $force_db=0, $class='avatar') 77 77 { 78 78 if ($a = avatarupload_get_avatar($id,1,$force_db)) 79 79 { 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.'" />'; 81 81 } else { 82 82 $config = new avatarupload_config(); … … 86 86 // Use a "genric" default avatar 87 87 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.'" />'; 89 89 } else { 90 90 // Or use Identicons instead. New users will have an identicon automatically … … 96 96 if ($a = avatarupload_get_avatar($id,1,$force_db)) 97 97 { 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.'" />'; 99 99 } 100 100 } … … 110 110 $cached = bb_get_user($id); 111 111 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) 127 115 { 128 116 $bb_query = "SELECT meta_value FROM $bbdb->usermeta WHERE meta_key='avatar_file' AND user_id='$id' LIMIT 1"; … … 134 122 return false; 135 123 } 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 138 136 // do we want the full uri? 139 137 if ($fulluri == 1) … … 156 154 } 157 155 add_action( 'bb_profile_menu', 'add_avatar_tab' ); 158 159 156 160 157 // bbPress Identicon function by Fel64 avatar-upload/trunk/readme.txt
r532 r568 4 4 Requires at least: 0.8.2 5 5 Tested up to: 0.8.2.1 6 Stable Tag: 0.8. 16 Stable Tag: 0.8.2 7 7 8 8 Allows 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. … … 38 38 == Installation == 39 39 40 IMPORTANT: 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 46 For 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 40 48 UPGRADING? 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. 41 49 … … 67 75 68 76 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. 69 79 70 80 4. OPTIONAL: open up `my-templates/avatar.php` and edit the template if you wish, but be sure not to mess with the upload form. … … 133 143 134 144 == Change Log == 145 2007-08-07 Ver. 0.8.2 Bug-fix (default avatars not displaying). Added a classname ('avatar') to img tag. 146 135 147 2007-08-02 Ver. 0.8.1 Bug-fix, plus improved cache support that should have been in previous update. 136 148
