PHP Classes

Unsplash Helper: Display images from Unsplash.com

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 62 All time: 10,456 This week: 524Up
Version License PHP version Categories
image-unsplash 1.0MIT/X Consortium ...7.1Graphics, Web services, PHP 7
Description 

Author

This class can display images from Unsplash.com.

It can take the image identifier of a image from Unsplash.com and generates a URL for an image that can be include in a Web page with img tag.

The class can also take other parameters for the image like the width and height, automatic fit, quality and device pixel ratio.

Picture of Pierre-Henry Soria
  Performance   Level  
Name: Pierre-Henry Soria <contact>
Classes: 49 packages by
Country: United Kingdom
Innovation award
Innovation award
Nominee: 18x

Winner: 3x

Documentation

Unsplash Helper

Get Unsplash Images Easily

Get easily any Unsplash images with a clean PHP class.

It's a really lightweight and simple PHP class that helps you to get easily any images from Unsplash.com while keeping your project clean.

Example

use PH7\Image\Unsplash;

$unsplash = new Unsplash();
$unsplash->setWidth(600)
    ->setHeight(400)
    ->setQuality(80)
    ->setImageId('photo-1462045504115-6c1d931f07d1');

echo '<img src="' . $unsplash->getImage() . '">';

$unsplash->setImageId('photo-1500045992661-f978470eaf7b');
$unsplash->setFit(Unsplash::MAX_FIT);

echo '<img src="' . $unsplash->getImage() . '">';

Installation

  1. Install Composer (https://getcomposer.org)
  2. Include it in your project:
    composer require ph-7/image-unsplash
    

Requirements

Author

Made with ? and care by Pierre-Henry Soria

License

MIT License. Enjoy! :smiley:


  Files folder image Files (7)  
File Role Description
Files folder imagesrc (1 directory)
Files folder imagetests (1 directory)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file phpunit.xml.dist Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files (7)  /  src  
File Role Description
Files folder imageImage (3 files)

  Files folder image Files (7)  /  src  /  Image  
File Role Description
  Plain text file InvalidAutoException.php Class Class source
  Plain text file InvalidFitException.php Class Class source
  Plain text file Unsplash.php Class Class source

  Files folder image Files (7)  /  tests  
File Role Description
Files folder imageImage (1 file)

  Files folder image Files (7)  /  tests  /  Image  
File Role Description
  Plain text file UnsplashTest.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:62
This week:0
All time:10,456
This week:524Up