https://github.com/drago-ex/gravatar
:performing_arts: Simple and customizable Gravatar integration for PHP applications, allowing easy Gravatar image generation based on user email with options for size, default image, and rating.
https://github.com/drago-ex/gravatar
gravatar nette
Last synced: 5 months ago
JSON representation
:performing_arts: Simple and customizable Gravatar integration for PHP applications, allowing easy Gravatar image generation based on user email with options for size, default image, and rating.
- Host: GitHub
- URL: https://github.com/drago-ex/gravatar
- Owner: drago-ex
- License: mit
- Created: 2020-04-08T10:12:02.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2025-01-24T12:13:45.000Z (over 1 year ago)
- Last Synced: 2025-10-06T22:58:00.510Z (9 months ago)
- Topics: gravatar, nette
- Language: PHP
- Homepage:
- Size: 60.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license.md
Awesome Lists containing this project
README
## Drago Gravatar
Simple and customizable Gravatar integration for PHP applications.
[](https://raw.githubusercontent.com/drago-ex/gravatar/master/license)
[](https://badge.fury.io/ph/drago-ex%2Fgravatar)
[](https://github.com/drago-ex/gravatar/actions/workflows/tests.yml)
[](https://github.com/drago-ex/gravatar/actions/workflows/coding-style.yml)
[](https://www.codefactor.io/repository/github/drago-ex/gravatar)
[](https://coveralls.io/github/drago-ex/gravatar?branch=master)
## Requirements
- PHP >= 8.3
- Nette Framework
- Composer
## Installation
```
composer require drago-ex/gravatar
```
## Overview
Drago Gravatar is a simple, customizable solution for integrating Gravatar images into your PHP
application. With this package, you can easily generate and display Gravatar images based
on user email addresses, allowing you to customize their size, default image, and rating.
## Features
- Generate Gravatar images based on user email.
- Customizable image size (from 1 to 2048 pixels).
- Choose a default image if the user has no Gravatar.
- Set image rating (g, pg, r, x).
- Easy integration into your Nette-based application.
## Extension registration
After installation, register the extension in your Nette configuration (`neon` file):
```neon
extensions:
- Drago\User\DI\GravatarExtension(size: 80, defaultImage: 'mm', rating: 'g')
```
You can adjust the size, `defaultImage`, and rating parameters based on your needs.
## Usage
Once the extension is registered, you can use the Gravatar functionality in your presenters and templates.
## In Presenter
In your presenter, you can access the Gravatar service, set the user's email, and pass
the generated Gravatar URL to the template:
```php
$gravatar = $this->gravatar;
$gravatar->setEmail('someone@somewhere.com');
$this->template->gravatar = $gravatar->getGravatar();
```
## In Template
In your Latte template, simply output the Gravatar image by using the URL provided by the presenter:
```latte
```
## Customizing Gravatar
You can customize the Gravatar by changing the size, defaultImage, and rating parameters in the configuration:
`size`: The size of the Gravatar image in pixels (1 to 2048). Default is 80.
`defaultImage`: The default image used when the user doesn't have a Gravatar (e.g., `mm`, `identicon`, `monsterid`, `wavatar`, etc.). Default is `mm`.
`rating`: The rating of the Gravatar image (`g`, `pg`, `r`, `x`). Default is g.