I am not sure if there is a solution in the PHP, I suspect it is in using something different for my CSS to center images. But it is close to midnight in Toronto and I am tired I hope it is a quick spot and someone can get me going again.
in php there are functions for handling BBCode. there is a function BBCode_Create to create BBCode which returns a value that has to be used with the function bbcode_parse(<return value from bbcode_create>, ); this should return the required image tag.
bbcode is best used to simplify the code that the end user has to type to a bare minimum. Giving someone a bbcode that takes 3 attributes defeats the purpose of making it bbcode in the first place. If I were tackling this I’d make the bbcode simply
[flag]Canada[/flag]
And whatever definitions file deciphers the flag bbcode knows what the target image is, and what the alt text is (which should by the way be something like “Image of the National Flag of Canada” - not the filename - alt is for text readers, particularly those for the blind, so a filename is pointless as alt text.
for the purpose of getting image file and alt value from within the pair you need to use regular expression. If using php you can use for example preg_match(‘’,$data, $match); where $match[0] and $match[1] will give you the required value.