Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pscourtney/blazorgravatar
A Gravatar blazor component for use in Blazor SSR, Server or WASM
https://github.com/pscourtney/blazorgravatar
blazor blazor-example blazor-server blazor-wasm blazor-webassembly dotnet dotnet-core gravatar gravatar-api gravatar-url
Last synced: 27 days ago
JSON representation
A Gravatar blazor component for use in Blazor SSR, Server or WASM
- Host: GitHub
- URL: https://github.com/pscourtney/blazorgravatar
- Owner: PSCourtney
- License: mit
- Created: 2024-11-22T10:59:55.000Z (2 months ago)
- Default Branch: master
- Last Pushed: 2024-11-27T12:51:01.000Z (about 2 months ago)
- Last Synced: 2024-12-27T15:35:59.224Z (29 days ago)
- Topics: blazor, blazor-example, blazor-server, blazor-wasm, blazor-webassembly, dotnet, dotnet-core, gravatar, gravatar-api, gravatar-url
- Language: CSS
- Homepage: https://www.nuget.org/packages/BlazorGravatar
- Size: 753 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# BlazorGravatar https://github.com/PSCourtney/BlazorGravatar
![NuGet Downloads](https://img.shields.io/nuget/dt/BlazorGravatar?label=NuGet%20Downloads&color=blue)
![License](https://img.shields.io/github/license/PSCourtney/BlazorGravatar)
![Last Commit](https://img.shields.io/github/last-commit/PSCourtney/BlazorGravatar)The **BlazorGravatar** library is a Blazor component that generates Gravatar profile images based on email addresses. It supports customizable image sizes, classes, alt text, and fallback options for default images and ratings.
## 📒 Features
- Automatically generates a Gravatar image URL based on the provided email address.
- Supports optional parameters for customizing image size, default fallback image, and rating level.
- Easy-to-use Razor syntax for integration into your Blazor project.## 🛠 Installation
1. Install the NuGet package (replace `` with the latest version):
```bash
dotnet add package BlazorGravatar --version
```2. Add the namespace to your `_Imports.razor` file for convenience:
```razor
@using BlazorGravatar
```## 🚀 Usage
### 🔹 Basic Example
Render a Gravatar image for an email address:
```razor
```
### 🔸 Custom Size, Class, and Default Image
```razor
```
## ⚙️ Parameters
| Parameter | Type | Description | Default |
| -------------- | -------- | ------------------------------------------------------------------------------------------- | ------- |
| `Email` | `string` | **Required**. The email address used to fetch the Gravatar image. | N/A |
| `Class` | `string` | CSS class to style the `` element. | `null` |
| `Alt` | `string` | Alternative text for the `` element. | `null` |
| `Size` | `int?` | Image size in pixels. Must be between `1` and `2048`. | `null` |
| `DefaultImage` | `string` | Default image if no Gravatar is found. Options: `404`, `mp`, `identicon`, `monsterid`, etc. | `"mp"` |
| `Rating` | `string` | Maximum rating of images allowed: `g`, `pg`, `r`, or `x`. | `"g"` |## 🖼️ Supported Default Images
- `404`: Do not load any image; return an HTTP 404 instead.
- `mp`: Mystery Person silhouette (default).
- `identicon`: Geometric pattern based on email hash.
- `monsterid`: Monster face generated based on email hash.
- `retro`: 8-bit arcade-style image.
- And more... see [Gravatar's official documentation](https://en.gravatar.com/site/implement/images/).## 🎨 Example with Styling
Add custom styles for the Gravatar image:
```razor
```
```css
/* Custom CSS */
.rounded-circle {
border-radius: 50%;
}.shadow-sm {
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
```## ⚙️ How It Works
The **BlazorGravatar** component normalizes the email address (lowercase and trimmed), computes an SHA256 hash, and generates the Gravatar URL. Optional parameters like size, default image, and rating are added as query parameters.
## 🤝 Contributing
1. Fork the repository.
2. Create a new branch for your feature or bug fix.
3. Commit and push your changes.
4. Submit a pull request with a detailed explanation of your changes.## 📄 License
This project is licensed under the [MIT License](LICENSE).
## 🙏 Acknowledgments
The Gravatar API is provided by [Gravatar.com](https://gravatar.com).