PHP code example of ph-7 / image-unsplash
1. Go to this page and download the library: Download ph-7/image-unsplash library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ph-7 / image-unsplash example snippets
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() . '">';