$src = '../LICENSE-ICONS-3RD-PARTY.json';
// check for ajax request
if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
return file_put_contents($src, json_encode($_POST['list'], JSON_PRETTY_PRINT));
exit();
}
?>
# Path to image folder
$imageFolder = '../public/assets/images/icons/';
# Show only these file types from the image folder
$imageTypes = '{*.svg}';
# Set to true if you prefer sorting images by name
# If set to false, images will be sorted by date
$sortByImageName = false;
# Set to false if you want the oldest images to appear first
# This is only used if images are sorted by date (see above)
$newestImagesFirst = true;
date_default_timezone_set('Europe/Berlin');
# The rest of the code is technical
# Add images to array
$images = glob($imageFolder . $imageTypes, GLOB_BRACE);
$author_data = json_decode(file_get_contents($src), true);
# Sort images
if ($sortByImageName) {
$sortedImages = $images;
natsort($sortedImages);
} else {
# Sort the images based on its 'last modified' time stamp
$sortedImages = array();
$count = count($images);
for ($i = 0; $i < $count; $i++) {
$sortedImages[date('YmdHis', filemtime($images[$i])) . $i] = $images[$i];
}
# Sort images in array
if ($newestImagesFirst) {
krsort($sortedImages);
} else {
ksort($sortedImages);
}
}
?>
foreach ($sortedImages as $image): ?>
# Get the name of the image, stripped from image folder path and file type extension
$filename = basename($image);
$name = preg_replace('/\\.[^.\\s]{3,4}$/', '', $filename);
if(!array_key_exists($filename, $author_data)){
$author_data[$filename] = array(
'author' => '',
'url' => '',
'license' => ''
);
}
# Begin adding
?>
= file_get_contents($image) ?>
endforeach ?>