PHP code example of mitogh / random-image

1. Go to this page and download the library: Download mitogh/random-image 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/ */

    

mitogh / random-image example snippets


composer 





$randomImage = new mitogh\RandomImage();

$args = array(
  'count' => 3,
  'parent_ID' => 2,
);
$randomImage = new mitogh\RandomImage( $args );

image/jpeg
image/gif
image/png
image/bmp
image/tiff

add_filter( 'mitogh_rand_image_mime_type', function( $default_types ) ) {
    return array(
		'image/gif',
    );
});

$randomImage = new mitogh\RandomImage();
$images_id = $randomImage->get_ids();
// Now images_id has an array with the id of each image, and you can use 
// each id to operate over each image.

$randomImage = new mitogh\RandomImage();
$images_src = $randomImage->get_srcs( 'full' );
// Now images_src has an array with the src value of the images with the
// full size.