I remembered this thread, so I think the snippet ContentID
should be
<?php
$search_pattern="/\[\[~(\d+)\]\]/";
if (preg_match($search_pattern, $input, $match)){
return $match[1];
} else {
return $input;
}
but it is still not a clean solution as it creates a lot of “Could not find snippet” errors for all the non weblink resources.