Is it possible to append a unique ID to the SVG identifier?
This should avoid trouble with same named SVG files from diffrent folders on same page, eg:
$fileAbsPath = GeneralUtility::getFileAbsFileName($file);
// early return if it seems that the file does not exist (is_file or file_exists, not sure here)
if (!is_file($fileAbsPath)) {
return '<!-- Please check path: ' . $file . ' -->';
}
$this->assetCollector->addXmlFile($fileAbsPath);
// feed in absolute path, to have same value as in AssetCollector Class
$iconIdentifier = $this->assetCollector->getIconIdentifierFromFileName($fileAbsPath);
and in the AssetCollector.php ~118 then:
public function getIconIdentifierFromFileName(string $xmlFile): string
{
// maybe other approach here for unique ID without messing up generated HTML to much
$uniqueId = substr(sha1($xmlFile), 0, 8);
return str_replace('.svg', '', basename($xmlFile)) . '-'. $uniqueId;
}
and in the AssetCollector.php ~102, too:
public function addXmlFile(string $xmlFile): void
{
// maybe security check, if file is in public path and a SVG file (is_file or file_exists, not sure here)
if (file_exists($xmlFile)) {
$this->xmlFiles[] = $xmlFile;
} else {
$xmlFile = preg_replace('/^\//', '', $xmlFile); // or: ltrim($xmlFile, '/');
$this->xmlFiles[] = GeneralUtility::getFileAbsFileName($xmlFile);
}
}
Best regards and many thanks for the extension :-)
Is it possible to append a unique ID to the SVG identifier? This should avoid trouble with same named SVG files from diffrent folders on same page, eg:
Maybe change the SvgViewHelper.php from ~66:
to:
and in the AssetCollector.php ~118 then:
and in the AssetCollector.php ~102, too:
Best regards and many thanks for the extension :-)