XF 1.5 Importing Orphaned Attachments


Active member
Is there a way to import orphaned attachments from vBulletin 4? We have images that are included using the URL of the attached image in posts other than the one they were originally uploaded to. vBulletin doesn't care that these were deleted from the original post, but they're lost on import because they have no post ID so are broken in XF.

Or at least that's what I think is happening. :p

I thought about giving any attachment with no post ID a post ID and seeing what happens on a fresh import, but I was wondering if there's a way to import these separately.

Thanks for any insight!
If the attachment is actually orphaned, there wouldn't be a way to import them; conceptually, attachments have to be connected to content as they inherit permissions from the content. I can't see an obvious way of working around this.
To be honest, I'm assuming that it's orphaned since there's no attachment by the same ID in XF that was in vb (I kept IDs the same on import). I might be misunderstanding what orphaned means in this case.

I considered making a post in a protected forum to get a post ID, then adding that to any image in the vb attachment table that lacks a post ID. I'm not sure if that would matter though.
Aside from the attached content not being found, the only other reason for an attachment to not be imported is if the file wasn't found. That doesn't seem totally likely, but it's possible. Orphaning seems more likely, but I'm not sure.

If you did attach them to a post in a private forum, that wouldn't strictly solve the problem as they would still respect the permissions from that forum (so you'd have to make it viewable at least).
That makes sense. They're in this state because of changes I made; basically the posts the images are on used to be "articles" in vb4's CMS system, and we turned that off and moved them into other forums. The reduced screen area of forum posts vs articles meant that many of the post layouts didn't work so well, so I made a custom BBCode tag to give us more control where xxx is an integer specifying width:


Basically the allowed me to do a find/replace of the raw code of the post and change instances of [ attach ] xxxxxx [ /attach] to the format above, then tweak values for each so everything looked good.

In XF I made a custom BBCode with PHP callback to change the URL format to match XF attachment structure, and that works fine. This is also fortunately limited to a set of official site posts and not user posts, since I didn't add an icon to CKEditor and it was really only used for the posts mentioned above. Not that I know exactly which posts at this point, lol. :oops::LOL:
A bit of followup...

As it turned out, the attachments weren't orphaned- or at least not in vB. In vB, the attachments all had a contentid of 24 (articles), whereas everything that was imported had a contentid of 1 (posts). This made sense since while we might have moved the posts out of the original forum used for articles, they were still originally created as such. It also made sense why they weren't imported because they weren't recognized as post attachments, or at least that's my theory and I'm going to run with that. :p

Anyway, I nuked the test db and did a fresh import, only this time I installed this add-on beforehand:


It's not maintained, though it worked fine for importing all of the article attachments separately after posts and attachments had been imported by native XF. Success!
Last edited:
Top Bottom