Multiavatar 诊断工具
为您的WordPress站点带来独特的SVG头像生成功能
by actonmartin · github.com/actonmartin/multiavatarforwordpress
Install
The author publishes release zips, so WP-CLI can install straight from GitHub:
wp plugin install https://github.com/actonmartin/multiavatarforwordpress/releases/download/V1.0.0/multiavatar-wordpress-v1.0.0.zipEnglish
A WordPress plugin that integrates Multiavatar to generate unique SVG avatars. Supports shortcodes, automatic avatar replacement, and more.
🌟 Features
- ✅ Official Multiavatar Library - Uses the official Multiavatar PHP library
- ✅ 48 Unique Designs - Robots, girls, aliens, bears, birds, and more
- ✅ 12+ Billion Combinations - 12,230,590,464 unique avatars possible
- ✅ Deterministic Algorithm - Same text always generates the same avatar
- ✅ SVG Format - Scalable without quality loss
- ✅ Shortcode Support - Easy to use in posts and pages
- ✅ Avatar Replacement - Automatically replace WordPress default avatars
- ✅ Settings Page - Configure options with a user-friendly interface
- ✅ Caching Support - Improve performance with built-in caching
- ✅ Multilingual - Supports multiple languages
📦 Installation
Method 1: WordPress Plugin Upload (Recommended)
- Download the latest release
- Go to WordPress Admin → Plugins → Add New → Upload Plugin
- Choose the ZIP file and click "Install Now"
- Activate the plugin
Method 2: Manual Installation
- Upload the
multiavatar-wordpressfolder to/wp-content/plugins/ - Activate the plugin through the WordPress Admin → Plugins menu
Method 3: Git Clone
cd /wp-content/plugins/
git clone https://github.com/ActonMartin/multiavatarForWordpress.git
🚀 Usage
1. Shortcode
Use in posts, pages, or widgets:
[multiavatar text="username" size="80"]
Parameters:
| Parameter | Description | Default |
|---|---|---|
| text | Text to generate avatar from (username, email, etc.) | Current user |
| size | Avatar size in pixels | 80 |
| class | CSS class name | multiavatar |
| id | Element ID | empty |
Examples:
// Display current user's avatar
[multiavatar]
// Display specific user's avatar
[multiavatar text="john"]
// Custom size
[multiavatar text="user@example.com" size="120"]
// With custom class and ID
[multiavatar text="john" class="my-avatar" id="user-avatar"]
2. Automatic Avatar Replacement
The plugin automatically replaces WordPress default avatars:
- Comment author avatars
- User profile avatars
- Admin bar avatars
- Any place using
get_avatar()
3. Settings Page
Configure options at WordPress Admin → Multiavatar:
- Replace User Avatars - Enable/disable automatic replacement
- Default Avatar Size - Set default size in pixels
- Enable Shortcode - Enable/disable shortcode functionality
- Cache Avatars - Enable/disable caching for better performance
- Clear Cache - Clear all cached avatars
🔧 How It Works
Algorithm
Input Text (e.g., "actonmartin")
↓
SHA256 Hash (64-character hex)
↓
Extract Numbers Only
↓
Take First 12 Digits
↓
Calculate 6 Parts (env, clo, head, mouth, eyes, top)
↓
Each Part: Design (00-47) + Theme (A/B/C)
↓
Generate SVG Avatar
Example
For input "actonmartin":
SHA256: 3cfff959bd30890d2ffe147edadd0b2012976afcb0b120fd8db721b9822b9743
First 12 digits: 395930890214
Parts:
- env: Design 02, Theme B
- clo: Design 12, Theme B
- head: Design 14, Theme A
- mouth: Design 10, Theme C
- eyes: Design 01, Theme A
- top: Design 07, Theme A
🎨 Customization
CSS Styling
.multiavatar {
border-radius: 50%;
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
transition: transform 0.3s ease;
}
.multiavatar:hover {
transform: scale(1.1);
}
PHP API
// Get plugin instance
$plugin = Multiavatar_WordPress::get_instance();
// Generate avatar SVG
$svg = $plugin->generate_avatar_svg('username');
// Generate avatar HTML
$html = $plugin->generate_avatar_html('username', 80, 'avatar-class');
JavaScript API
// Generate avatar
const svg = MultiavatarWP.generate('username', 100);
// Generate via AJAX
MultiavatarWP.generateAjax('username', 100, function(html) {
console.log(html);
});
// Replace element content
MultiavatarWP.replace('#avatar-container', 'username', 100);
🔍 Troubleshooting
Avatar doesn't match multiavatar.com
Cause: Cached old avatar data
Solution:
- Go to WordPress Admin → Multiavatar
- Click "Clear Cache" button
- Refresh the page (Ctrl+F5)
Avatar not displaying
Check:
- Plugin is activated
- Shortcode syntax is correct
- No JavaScript errors in browser console
- Multiavatar.php file exists (should be 79KB)
Cache won't clear
Solution:
- Use the diagnostic tool (
mav-diagnostic.php) - Or execute SQL directly:
DELETE FROM wp_options WHERE option_name LIKE '_transient_multiavatar_%';
📊 Performance
- Caching: Avatars are cached for 30 days by default
- SVG Size: Average 2-5KB per avatar
- Generation Time: < 10ms per avatar
- Memory Usage: Minimal (no external API calls)
🌐 Compatibility
- WordPress: 5.0 or higher
- PHP: 7.4 or higher
- Browsers: All modern browsers (SVG support required)
📝 Changelog
Version 1.0.0 (Current)
- ✅ Initial release
- ✅ Official Multiavatar library integration
- ✅ Shortcode support
- ✅ Avatar replacement
- ✅ Settings page
- ✅ Caching system
- ✅ Diagnostic tools
🤝 Contributing
Contributions are welcome! Please read CONTRIBUTING.md for details.
Development
# Clone the repository
git clone https://github.com/ActonMartin/multiavatarForWordpress.git
# Create a branch
git checkout -b feature/your-feature
# Make changes and commit
git commit -m "Add your feature"
# Push and create PR
git push origin feature/your-feature
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Credits
- Multiavatar - The avatar generation library
- WordPress - The platform this plugin is built for
💖 Support the Project
If this plugin helps you, consider supporting its development:
Sponsor
![]()
WeChat / Alipay donation QR code
Other Ways to Support
- ⭐ Star the repository
- 🐛 Report bugs
- 💡 Suggest features
- 📖 Improve documentation
- 🔀 Submit pull requests
📞 Support
- Documentation: README_CN.md (中文文档)
- Issues: GitHub Issues
- Multiavatar Official: multiavatar.com
🗺️ Roadmap
- [ ] WordPress.org plugin directory submission
- [ ] Gutenberg block support
- [ ] REST API endpoint
- [ ] Bulk avatar generation
- [ ] Avatar gallery shortcode
- [ ] Custom color themes
- [ ] Avatar export feature
Made with ❤️ by the Multiavatar Community
Releases
1 release. Each count is every asset in that release; expand a row for the breakdown.