public static function srcToInsertTag($data)
{
$return = '';
$paths = preg_split('/((src|href)="([^"]+)")/i', $data, -1, PREG_SPLIT_DELIM_CAPTURE);
for ($i = 0, $c = count($paths); $i < $c; $i = $i + 4) {
$return .= $paths[$i];
if (!isset($paths[$i + 1])) {
continue;
}
$file = \FilesModel::findByPath($paths[$i + 3]);
if ($file !== null) {
$return .= $paths[$i + 2] . '="{{file::' . static::binToUuid($file->uuid) . '}}"';
} else {
$return .= $paths[$i + 2] . '="' . $paths[$i + 3] . '"';
}
}
return $return;
}