diff options
| author | Jan-Hendrik Willms <tleilax+github@gmail.com> | 2021-09-13 16:20:32 +0200 |
|---|---|---|
| committer | Jan-Hendrik Willms <tleilax+github@gmail.com> | 2021-09-13 16:21:27 +0200 |
| commit | 6b1305bf27573c5547a50148c3168b3b22684bff (patch) | |
| tree | da5cf60ac79daf40797fab34970ace4e325c5eec /cli | |
| parent | bbaa44293faf4c7b7f5a47f2f0bcc7c580ce697d (diff) | |
add icon dimesions, add cli script that fixes that (will soon be reworked) and adjust svgo configuration, fixes #163
Diffstat (limited to 'cli')
| -rwxr-xr-x | cli/fix-icon-dimensions.php | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/cli/fix-icon-dimensions.php b/cli/fix-icon-dimensions.php new file mode 100755 index 0000000..a7e595a --- /dev/null +++ b/cli/fix-icon-dimensions.php @@ -0,0 +1,22 @@ +#!/usr/bin/env php +<?php +require_once __DIR__ . '/studip_cli_env.inc.php'; + +$folder = $GLOBALS['STUDIP_BASE_PATH'] . '/public/assets/images/icons'; +$iterator = new RecursiveDirectoryIterator($folder, FilesystemIterator::FOLLOW_SYMLINKS | FilesystemIterator::UNIX_PATHS); +$iterator = new RecursiveIteratorIterator($iterator); +$regexp_iterator = new RegexIterator($iterator, '/\.svg$/', RecursiveRegexIterator::MATCH); + +foreach ($regexp_iterator as $file) { + $contents = file_get_contents($file); + + $xml = simplexml_load_string($contents); + $attr = $xml->attributes(); + if ($attr->width && $attr->height) { + continue; + } + $contents = str_replace('<svg ', '<svg width="16" height="16" ', $contents); + file_put_contents($file, $contents); + + echo "Adjusted $file\n"; +} |
