Display a random image in a dashboard panel.
Requires ProcessWire Dashboard.
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'
]
]
]);
});wire()->addHookAfter('Dashboard::getPanels', function ($event) {
$panels = $event->return;
$panels->add([
'panel' => 'random-image',
'size' => 'small',
'data' => [
'dir' => 'dashboard/images', // relative to /site/templates/
]
]);
});Array of image URLs to pick from.
Directory name to look for images in.
Aspect ratio to enforce for all images, e.g. 1.5
How to fit images into the ratio container: cover or contain
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.
Pull requests are welcome.