I don't think we can keep this structure as-is. The anchor tag injection operation has to take place *before* the template is rendered, while the injection of MMS content must occur *after* rendering.

This isn't to say we can't limit anchor tag injection to SMS messages--I agree that is a more performant approach. We just cannot perform these two operations at the same point of this function.