2022-02-04 09:53:55 +00:00
|
|
|
<?php
|
2022-02-04 11:52:57 +00:00
|
|
|
/**
|
2022-07-19 16:38:55 +01:00
|
|
|
* ██ ██ ██ ███ ███ ██████
|
|
|
|
|
* ██ ██ ██ ████ ████ ██ ██
|
|
|
|
|
* ██ ██ ██ ██ ████ ██ ██████
|
|
|
|
|
* ██ ██ ██ ██ ██ ██ ██ ██
|
|
|
|
|
* █████ ██████ ██ ██ ██
|
2022-02-04 11:52:57 +00:00
|
|
|
*
|
|
|
|
|
* @author Dale Davies <dale@daledavies.co.uk>
|
2022-07-19 16:38:55 +01:00
|
|
|
* @copyright Copyright (c) 2022, Dale Davies
|
2022-02-04 11:52:57 +00:00
|
|
|
* @license MIT
|
|
|
|
|
*/
|
|
|
|
|
|
2022-07-19 16:38:55 +01:00
|
|
|
/**
|
|
|
|
|
* Generate dynamic CSS for randomising the background image.
|
|
|
|
|
*/
|
|
|
|
|
|
2022-02-04 09:53:55 +00:00
|
|
|
// Provided by composer for psr-4 style autoloading.
|
|
|
|
|
require __DIR__ .'/vendor/autoload.php';
|
|
|
|
|
|
|
|
|
|
$config = new Jump\Config();
|
2022-03-15 21:38:39 +00:00
|
|
|
|
|
|
|
|
$blur = floor((int)$config->get('bgblur', false) / 100 * 15);
|
|
|
|
|
$brightness = (int)$config->get('bgbright', false) ? (int)$config->get('bgbright', false) / 100 : 1;
|
2022-02-04 09:53:55 +00:00
|
|
|
|
2022-06-03 22:41:28 +01:00
|
|
|
$bgurlstring = '';
|
2022-06-30 11:26:28 +01:00
|
|
|
|
|
|
|
|
// Use unsplash API for background images if provided, otherwise use altbgprovider.
|
|
|
|
|
// If none of the above have been provided then fall back to local image.
|
2022-06-03 22:41:28 +01:00
|
|
|
if ($config->get('unsplashapikey', false) == null) {
|
2022-06-30 11:26:28 +01:00
|
|
|
if ($config->get('altbgprovider', false) != null) {
|
|
|
|
|
$backgroundimageurl = $config->get('altbgprovider', false);
|
|
|
|
|
} else {
|
|
|
|
|
$backgroundimageurl = (new Jump\Background($config))->get_random_background_file();
|
|
|
|
|
}
|
|
|
|
|
$bgurlstring = 'background-image: url("'.$backgroundimageurl.'");';
|
2022-06-03 22:41:28 +01:00
|
|
|
}
|
|
|
|
|
|
2022-02-04 09:53:55 +00:00
|
|
|
header('Content-Type: text/css');
|
2022-06-03 22:41:28 +01:00
|
|
|
echo '.background {'.$bgurlstring.'filter: brightness('.$brightness.') blur('.$blur.'px);}';
|