2020-07-27 09:35:34 +00:00
|
|
|
<?php
|
2020-08-04 11:25:22 +00:00
|
|
|
|
2021-06-08 09:52:11 +00:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2020-07-27 09:35:34 +00:00
|
|
|
/**
|
2022-02-19 16:06:11 +00:00
|
|
|
* @copyright 2020 Ad Aures
|
2020-07-27 09:35:34 +00:00
|
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
|
|
|
* @link https://castopod.org/
|
|
|
|
*/
|
|
|
|
|
2021-05-19 16:35:13 +00:00
|
|
|
if (! function_exists('svg')) {
|
2021-05-06 14:00:48 +00:00
|
|
|
/**
|
|
|
|
* Returns the inline svg image
|
|
|
|
*
|
|
|
|
* @param string $name name of the image file without the .svg extension
|
2022-07-03 16:42:20 +00:00
|
|
|
* @param string|null $class to be added to the svg string
|
2021-05-06 14:00:48 +00:00
|
|
|
* @return string svg contents
|
|
|
|
*/
|
|
|
|
function svg(string $name, ?string $class = null): string
|
|
|
|
{
|
2021-05-17 17:11:23 +00:00
|
|
|
$svgContents = file_get_contents('assets/images/' . $name . '.svg');
|
2021-05-06 14:00:48 +00:00
|
|
|
if ($class) {
|
2022-09-28 14:00:05 +00:00
|
|
|
return str_replace('<svg', '<svg class="' . $class . '"', $svgContents);
|
2021-05-06 14:00:48 +00:00
|
|
|
}
|
2022-03-04 14:33:48 +00:00
|
|
|
|
2021-05-17 17:11:23 +00:00
|
|
|
return $svgContents;
|
2020-08-27 10:05:44 +00:00
|
|
|
}
|
|
|
|
}
|