How to get the resource's ID from the returned uri?

Maybe the variable $input has still the value [[~22]] when the snippet ContentID is called.
You could test if this works:

<?php
$search_pattern="/\[\[~(\d+)\]\]/";
if (preg_match($search_pattern, $input, $match)){
    return $match[1];
} else {
    return $input;
}
1 Like