XF 1.5 Custom Image Width bbcode

On my phpbb board, I had a custom bbcode for posting any image with a specified width. It was set up as:

I've set the bbcode up on my XF forum, and all old posts that I imported that used that bbcode are displaying correctly on the new forum.

However, anyone who uses the bbcode now ends up with tags thrown around the URL in the middle of their [imgwidth] tags. Here's how I have the custom bbcode set up on XF:

HTML replacement:

<a href="{text}" class="fancybox" title="Click to see full-size."><img src="{text}" class="imgwidthimg" style="width: {option}px; max-width: 100%;"></a>
Admittedly I'm not 100% sure I'm setting that up correctly. Can you give me any pointers on how to set that up the right way?