I’ve tags in following format spread all over my HTML enabled content entries:
<img alt="" src="{assets_2100:{filedir_12}HappyDog.jpg}" style="height:400px; width:100px">
I need to update all these in following format either via a PHP function before displaying at frontend or just update the MySQL once and for all:
<img alt="" src="/uploads/HappyDog.jpg" data-assetid="2100" data-filedir="12" data-filename="HappyDog.jpg" style="height:400px; width:100px”>
The “/uploads/’ directory path is applicable for all images!
These tags were carried over when migrated content from EE
Edited: Okay, so far I tried the following as first step to remove the {filedir_X} from address:
$parse_encoded = true;
$pattern = ($parse_encoded)
? '/(?:{|{)filedir_(\d+)(?:}|})/'
: '/{filedir_(\d+)}/';
if (preg_match_all($pattern, $htmlcontent, $matches, PREG_SET_ORDER))
{
foreach ($matches as $match){
$htmlcontent = str_replace($match[0], '', $htmlcontent);
}
}
Then modified this to remove “{asset”, but ending up with “}” at the “src” attribute!