Correcting url/attach references


Well-known member
Prior to XF days, my site was integrated with A users image uploads were automatically stored at and the post with URL link and embedded display via IMG tags, so that the image showed directly within the post via [IMG ] tags.

At some stage I used to import/attach hot linked images into XF storage.

The bb code reference to these images is now, for example:
Attachment ID 83645 exists at data/attachments/83/83643-<redacted>.jpg

At the time of running the above add-on (to import hot linked images) the IMG tags didn't work correctly, and thus it's imported a placeholder stub from PostImage ...


PostImage's old URL format of is automatically redirected by PostImage server to new URL of

I would like to achieve one of two options;
  1. Use find/replace add-on, or direct SQL query, to adjust the above bb code and remove the [ATTACH ] tags so that it only leaves the existing URL hyperlink. Bonus if I there was a way to map the old URL to the new URL, and replace the URL too.
  2. Replace the stub image file stored at data/attachments/83/ with the real image file from PostImage.
Appreciate thoughts, especially regex for achieving option 1. My regex skills are terrible.