Skip to content

daun/processwire-dashboard-panel-random-image

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ProcessWire Dashboard Panel: Random Image

Display a random image in a dashboard panel.

Requires ProcessWire Dashboard.

Usage

Pick from list of URLs

wire()->addHookAfter('Dashboard::getPanels', function ($event) {
    $panels = $event->return;

    $panels->add([
        'panel' => 'random-image',
        'size' => 'small',
        'data' => [
            'images' => [
                'https://via.placeholder.com/150/0000FF/808080',
                'https://via.placeholder.com/150/FF0000/FFFFFF',
                'https://via.placeholder.com/150/FFFF00/000000',
                'https://via.placeholder.com/150/000000/FFFFFF'
            ]
        ]
    ]);
});

Pick from images in a folder

wire()->addHookAfter('Dashboard::getPanels', function ($event) {
    $panels = $event->return;

    $panels->add([
        'panel' => 'random-image',
        'size' => 'small',
        'data' => [
            'dir' => 'dashboard/images', // relative to /site/templates/
        ]
    ]);
});

Options

images

Array of image URLs to pick from.

dir

Directory name to look for images in.

ratio

Aspect ratio to enforce for all images, e.g. 1.5

fit

How to fit images into the ratio container: cover or contain

cache

Optionally cache the result of the random pick, à la Photo of the Day.

Takes any value accepted by WireCache: 3600, hourly, daily, tomorrow midnight, etc.

Contributing

Pull requests are welcome.

License

GPL-3.0

About

Display a random image in a dashboard panel

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages