I am looking for help with regular expression $pattern to convert inline image tags like [image:123:title:size] into HTML img tags.
here is the code:
//[image:ID:caption:size]
$content = '[image:38:title:800x900]';
preg_match_all( '/\[image:(\d+)(:?)([^\]]*)\]/i', $content, $images );
if( !empty( $images[0] ) )
{ // There are image inline tags in the content
foreach( $images[0] as $i => $tag )
{
$link_ID = (int)$images[1][$i];
$caption = empty( $images[2][$i] ) ? '#' : $images[3][$i];
$size = empty( $images[4][$i] ) ? '#' : $images[5][$i];
}
echo '<br />';
echo 'ID: '.$link_ID.'<br />';
echo 'Tag: '.$caption.'<br />';
echo 'size: '.$size.'<br />';
}
which outputs:
image id: 12
Title: caption:size
size: #
but should output this:
image id: 12
Title: caption
size: size
this---> /[image:(\d+)(:?)([^]]*)]/i
does not work
Any help would be great!