A Laravel Gravatar package for retrieving gravatar image URLs or checking the existance of an image.

Related tags

Imagery gravatar
Overview

Gravatar for Laravel 5.x, 6, 7 and 8

Total Downloads Latest Stable Version License

Installation

First, pull in the package through Composer via the command line:

composer require creativeorange/gravatar ~1.0

or add the following to your composer.json file and run composer update.

"require": {
    "creativeorange/gravatar": "~1.0"
}

Then include the service provider within (Laravel 5.3 or below) app/config/app.php.

'providers' => [
    'Creativeorange\Gravatar\GravatarServiceProvider'
];

If using Laravel 5.4, include service provider withing config/app.php

'providers' => [
    Creativeorange\Gravatar\GravatarServiceProvider::class
];

If you want to use the facade, add this to de bottom of app/config/app.php And, for convenience, add a facade alias to this same file at the bottom:

'aliases' => [
    'Gravatar' => 'Creativeorange\Gravatar\Facades\Gravatar',
];

If you are using Laravel 5.4 or greater, add as follows, add to config/app.php

'aliases' => [
    'Gravatar' => Creativeorange\Gravatar\Facades\Gravatar::class,
];

Finally, publish the config by running the php artisan vendor:publish command

Usage

Within your controllers or views, you can use

    Gravatar::get('[email protected]');

this will return the URL to the gravatar image of the specified email address. In case of a non-existing gravatar, it will return return a URL to a placeholder image. You can set the type of the placeholder in the configuration option fallback. For more information, visit gravatar.com

Alternatively, you can check for the existence of a gravatar image by using

    Gravatar::exists('[email protected]');

This will return a boolean (true or false).

Or you can pass a url to a custom image using the fallback method:

    Gravatar::fallback('http://urlto.example.com/avatar.jpg')->get('[email protected]');

Configuration

You can create different configuration groups to use within your application and pass the group name as a second parameter to the get-method:

There is a default group in config/gravatar.php which will be used when you do not specify a second parameter.

If you would like to add more groups, feel free to edit the config/gravatar.php file. For example:

return array(
	'default' => array(
		'size'   => 80,
		'fallback' => 'mm',
		'secure' => false,
		'maximumRating' => 'g',
		'forceDefault' => false,
		'forceExtension' => 'jpg',
	),
	'small-secure' => array (
	    'size'   => 30,
	    'secure' => true,
	),
	'medium' => array (
	    'size'   => 150,
	)
);

then you can use the following syntax:

Gravatar::get('[email protected]', 'small-secure'); // will use the small-secure group
Gravatar::get('[email protected]', 'medium'); // will use the medium group
Gravatar::get('[email protected]', 'default'); // will use the default group
Gravatar::get('[email protected]'); // will use the default group

Alternatively, you could also pass an array directly as the second parameter as inline options. So, instead of passing a configuration key, you pass an array, which will be merged with the default group:

Gravatar::get('[email protected]', ['size'=>200]); 
Comments
  • Use HTTPS all the time

    Use HTTPS all the time

    This library should just use HTTPS all the time for Gravatar. There's no reason not to. Using HTTPS inside of a site that is currently using HTTP doesn't cause any problems, but clearly the reverse is not true.

    HTTPS forever! πŸ˜‰

    opened by joshlewis 4
  • Request - inline options

    Request - inline options

    Love this package! It would be really nice to be able to set some options inline, such as the size. Finding that I am duplicating my configuration array several times for different image sizes.

    Sorry, not familiar with how to label this as a request.. :)

    opened by opheliadesign 3
  • Fix Typehint of Gravatar::get

    Fix Typehint of Gravatar::get

    \Creativeorange\Gravatar\Facades\Gravatar::get($email, $configGroup)

    $configGroup needs to match the type in setConfig, otherwise, the IDE will warn that there's a type mismatch and we can't set an array as an option.

    opened by usernotnull 2
  • checkEmail() function cause a validation problem

    checkEmail() function cause a validation problem

    private function checkEmail($email) use filter_var() function with FILTER_VALIDATE_EMAIL as a second parameter. This is a problem because Laravel's email validator use different check for email. For example Laravel consider maxim@localhost as a valid email, but FILTER_VALIDATE_EMAIL does not.

    Please, consider to change filter_var() with FILTER_VALIDATE_EMAIL to standard Laravel 'email' validator

    opened by mkovtun-smartech 2
  • V1.0.10 not really loading

    V1.0.10 not really loading

    Hello

    When I install the package with composer it says that it installs the V1.0.10, but when I look at the vendor I see that composer.json doesn't have the discovery option for Laravel 5.5. So this is not the last version that is uploaded. I made the intallation many times and always the same result even if I clear composer cache...

    opened by bestmomo 2
  • Update Gravatar.php

    Update Gravatar.php

    Sometimes I code without an internet connection. When this happens, the package returns an error due to the get_headers() PHP function, inside exists() function.

    Adding a @ before function, exists() will return FALSE whenever the user is not connected to the internet. So solving the problem.

    What do you think?

    opened by carlos3duardo 2
  • Exists always returns true

    Exists always returns true

    First, thanks for library. I found that Gravatar::exists() always returns true no matter what address you enter. Could I suggest you add the following as a check as this will return the right bool:

                $email= "[email protected]"; //for testing
                        $gravemail = md5( strtolower( trim( $email ) ) );
                        $gravImage = "http://www.gravatar.com/avatar/".$gravemail;
                        $gravcheck = "http://www.gravatar.com/avatar/".$gravemail."?d=404";
                        $response = get_headers($gravcheck);
                        print_r($response);
                        if ($response[0] != "HTTP/1.0 404 Not Found"){
                            echo('FOUND');
                            $img = $gravImage;
                        } else {
                            echo('FOUND');
                            // execute fallback
                        }
    
    opened by nolros 2
  • Laravel 5.2 bindShared deprecated

    Laravel 5.2 bindShared deprecated

    Hey,

    just upgraded my application to Laravel 5.2, but I get an error because of this deprecated function "bindShared". (http://laravel.com/docs/5.2/upgrade#upgrade-5.2.0)

    Is this package really ready for Laravel 5.2? Could you update the package?

    Cheers Christoph

    opened by christophrumpel 2
  • Adds support for Laravel 9

    Adds support for Laravel 9

    Since Laravel 9 will be launched in 6 days (Jan 25th 2022), I thought we could provide support even before the launch.

    This package already works well with Laravel 9, it just needs a dependency version bump. Proof it works like a charm in Laravel 9 too: Screenshot 2022-01-19 at 19 45 43 Screenshot 2022-01-19 at 19 50 50

    Thanks for a great package @jacotijssen ! πŸ™

    Let me know if there's anything I can do to get this merged. Cheers!

    opened by tabacitu 1
  • fallback broken

    fallback broken

    After a change in https://github.com/creativeorange/gravatar/blob/9057d98b51f023746740398d725afe9650e66f19/src/Gravatar.php#L220 it doesn't take fallback from config when used like: Gravatar::get('[email protected]') because $this->fallback is null by default.

    opened by waclaw66 1
  • Gravatar::fallback()

    Gravatar::fallback()

    I am using like below

    $data['gravatar'] = (!empty(auth()->user()->email)) ? Gravatar::fallback(url('images/user.jpg'))->get(auth()->user()->email) : null;

    But why my output is like below ?

    <img id="userImg" class="userImg" src="https://secure.gravatar.com/avatar/a516098e1de8e2756fa4bf045c7a4cb2.jpg?s=150&amp;d=http%3A%2F%2F127.0.0.1%3A8000%2Fimages%2Fuser.jpg&amp;r=g" alt="user">

    Could anyone help me in this regard ?

    opened by afoysal 1
Releases(v1.0.22)
Owner
Creativeorange
Creativeorange
Image Cache is a very simple PHP class that accepts an image source and will compress and cache the file, move it to a new directory, and returns the new source for the image.

NO LONGER MAINTAINED!!! Image Cache v. 1.0.0 Image Cache is a very simple PHP class that accepts an image source and will compress and cache the file,

Erik Nielsen 455 Dec 30, 2022
Create material deisgn avatars for users just like Google Messager. It may not be unique but looks better than Identicon or Gravatar.

Material-Design-Avatars Create material deisgn avatars for users just like Google Messager. It may not be unique but looks better than Identicon or Gr

Canbin Lin 268 Sep 14, 2022
Plug n play avatar, turn name, email, and any other string into beautiful avatar (or gravatar), effortless.

laravolt/avatar Display unique avatar for any user based on their (initials) name. Preview Installation This package originally built for Laravel, but

Laravolt 1.7k Jan 3, 2023
Auto Image & file upload, resize and crop for Laravel eloquent model using Intervention image

Laravel ImageUp The qcod/laravel-imageup is a trait which gives you auto upload, resize and crop for image feature with tons of customization. Install

QCode.in 708 Dec 22, 2022
This plugin adds a new image style for the Core Image block.

This plugin adds a new image style for the Core Image block. Introduction How to use? Go to Gutenberg Editor and add a image block. e.g. Add new image

Mahesh Waghmare 3 Feb 17, 2022
Picasso is a Laravel Image Management and Optimization Package

Picasso is a Laravel Image Management and Optimization Package. Define image dimensions and options, store uploaded image in multiple dimensions with or without a watermark and retrieve optimized images on your website when needed.

Laravelista 82 Nov 24, 2022
An open source image hosting service powered by Laravel

Limg An open source image hosting service powered by Laravel Features Upload your image via file, url or ShareX ! Manage your image (custom title, pub

Thomas 56 Dec 16, 2022
This is an image manipulation REST API written in PHP Laravel Framework

Laravel Image Manipulation REST API Demo Here is fully working Demo: https://www.lobiimages.com/ You have to register first in order to generate acces

TheCodeholic 42 Dec 15, 2022
PHP Image Manipulation

Intervention Image Intervention Image is a PHP image handling and manipulation library providing an easier and expressive way to create, edit, and com

null 13k Jan 3, 2023
PHP 5.3 Object Oriented image manipulation library

Imagine Tweet about it using the #php_imagine hashtag. Image manipulation library for PHP 5.3 inspired by Python's PIL and other image libraries. Requ

Bulat Shakirzyanov 4.3k Jan 6, 2023
Wonderfully easy on-demand image manipulation library with an HTTP based API.

Glide Glide is a wonderfully easy on-demand image manipulation library written in PHP. Its straightforward API is exposed via HTTP, similar to cloud i

The League of Extraordinary Packages 2.4k Dec 19, 2022
πŸŒ„ Perceptual image hashing for PHP

ImageHash A perceptual hash is a fingerprint of a multimedia file derived from various features from its content. Unlike cryptographic hash functions

Jens Segers 1.9k Dec 28, 2022
Image optimization / compression library. This library is able to optimize png, jpg and gif files in very easy and handy way. It uses optipng, pngquant, pngcrush, pngout, gifsicle, jpegoptim and jpegtran tools.

Image Optimizer This library is handy and very easy to use optimizer for image files. It uses optipng, pngquant, jpegoptim, svgo and few more librarie

Piotr Śliwa 879 Dec 30, 2022
:racehorse: find the size of an image without downloading the whole file. Supports batch requests.

FasterImage FasterImage finds the dimensions or filetype of a remote image file given its uri by fetching as little as needed, based on the excellent

Will Washburn 58 Nov 30, 2022
Extract colors from an image like a human would do.

ColorExtractor Extract colors from an image like a human would do. Install Via Composer $ composer require league/color-extractor:0.3.* Usage require

The League of Extraordinary Packages 1.2k Jan 1, 2023
php-gd based image templates

gdaisy A highly experimental image templating system based on PHP-GD to dynamically generate image banners and covers. Installation 1. Require erikahe

Erika Heidi 67 Nov 22, 2022
A simple page view counter that store data as text and shows data as a PNG image

Image Counter A simple page view counter that store data as text and shows the counter as a PNG image.

Victor Ribeiro 10 Apr 19, 2022
Grabs the dominant color or a representative color palette from an image. Uses PHP and GD, Imagick or Gmagick.

Color Thief PHP A PHP class for grabbing the color palette from an image. Uses PHP and GD or Imagick libraries to make it happen. It's a PHP port of t

Kevin Subileau 610 Dec 28, 2022
PHP library to easily edit image with GD extension. Resize, crop, merge, draw, and many more options !

PHP Image Editor PHP library to easily edit image with GD extension. Resize, crop, merge, draw, and many more options ! ✨ Supporting ⭐ Star this repos

Franck Alary 17 Nov 13, 2022