drago-ex/gravatar
Composer 安装命令:
composer require drago-ex/gravatar
包简介
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.
README 文档
README
Simple and customizable Gravatar integration for PHP applications.
Requirements
- PHP >= 8.3
- Nette Framework
- Composer
Installation
composer require drago-ex/gravatar
Extension Registration
After installation, register the extension in your Nette configuration (neon file):
extensions: gravatar: Drago\Gravatar\DI\GravatarExtension
Optional configuration
gravatar: size: 80 defaultImage: "mm" rating: "g"
You can adjust the size, defaultImage, and rating parameters based on your needs.
Examples
Once the extension is registered, you can use the Gravatar functionality in your presenters and templates.
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.
Using Gravatar in Presenters
Add the GravatarAdapter trait to your presenter:
use Drago\Gravatar\GravatarAdapter; protected function beforeRender(): void { parent::beforeRender(); $gravatar = $this->gravatar; $gravatar->setEmail('someone@somewhere.com'); $this->template->gravatar = $this->gravatar->getGravatar(); }
In Template
In your Latte template, simply output the Gravatar image by using the URL provided by the presenter:
<img src="{$gravatar}" alt="">
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.
drago-ex/gravatar 适用场景与选型建议
drago-ex/gravatar 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 199 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 05 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 drago-ex/gravatar 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 drago-ex/gravatar 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 199
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 24
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-05-20