• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Correcting postimage.org url/attach references

Mouth

Well-known member
#1
Prior to XF days, my site was integrated with PostImage.org. A users image uploads were automatically stored at postimage.org 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 https://xenforo.com/community/resources/convert-image.2521/ to import/attach hot linked images into XF storage.

The bb code reference to these images is now, for example:
Code:
[URL='http://www.postimage.org/image.php?v=aV4xChjS'][ATTACH=full]83645[/ATTACH][/URL]
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 postimage.org IMG tags didn't work correctly, and thus it's imported a placeholder stub from PostImage ...

aV4xChjS.png

PostImage's old URL format of http://www.postimage.org/image.php?v=aV4xChjS is automatically redirected by PostImage server to new URL of https://postimg.io/image/m19yewhyx/

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.