PHP code example of bluemmb / faker-picsum-photos-provider

1. Go to this page and download the library: Download bluemmb/faker-picsum-photos-provider 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/ */

    

bluemmb / faker-picsum-photos-provider example snippets


$faker = Faker\Factory::create();
$faker->addProvider(new Bluemmb\Faker\PicsumPhotosProvider($faker));

// simple usage
$url = $faker->imageUrl();              // https://picsum.photos/640/480
$url = $faker->imageUrl(500);           // https://picsum.photos/500/480
$url = $faker->imageUrl(500,500);       // https://picsum.photos/500/500

/*
 * $specificOrSeed
 *      - false | null : create simple url with no id or seed
 *      - true         : create id/{random id} url
 *      - int          : create id/{int} url
 *      - string       : create seed/{seed} url
 */
$url = $faker->imageUrl(500,500, false);    // https://picsum.photos/500/500
$url = $faker->imageUrl(500,500, true);     // https://picsum.photos/id/70/500/500
$url = $faker->imageUrl(500,500, true);     // https://picsum.photos/id/413/500/500
$url = $faker->imageUrl(500,500, 33);       // https://picsum.photos/id/33/500/500
$url = $faker->imageUrl(500,500, '33');     // https://picsum.photos/seed/33/500/500
$url = $faker->imageUrl(500,500, 'wow');    // https://picsum.photos/seed/wow/500/500

// Some image id's are invalid, So the package automatically replaces them
$url = $faker->imageUrl(500,500, 86);       // https://picsum.photos/id/82/500/500


/*
 *  More options :
 *  function imageUrl(
 *      $width = 640, $height = 480, $specificOrSeed=null, 
 *      $grayscale=null, $blur=null, $file_ending=null
 * )
 */
 
// https://picsum.photos/100/100?grayscale=true
$url = $faker->imageUrl(
    100,100, false, 
    true
);

// https://picsum.photos/g/100/100?blur=true
$url = $faker->imageUrl(
    100,100, false, 
    false, true
);

// https://picsum.photos/100/100?blur=5
$url = $faker->imageUrl(
    100,100, false, 
    false, 5
);

// https://picsum.photos/300/100.jpg
$url = $faker->imageUrl(
    300,100, false, 
    false, false, 'jpg'
);

// https://picsum.photos/id/88/300/100.webp?grayscale=true&blur=3
$url = $faker->imageUrl(
    300,100, 88,
    true, 3, 'webp'
);