XenForo-Import: Bilder und Galerien fehlen

Ok, so it looks like the vbulletin and vannila-mysql importers just strip the attachments out, but the answerbase importer actually supports them. As far as I can tell, it captures the file path from the post body, creates a new discourse upload and replaces the tag in the imported post with the html tags to reference the new upload.

This gives us a good starting point for XF uploads, but we have two additional hurdles:

  1. XF’s media tags don’t include the file’s path they are basically [ATTACH]{{id}}[/ATTACH] or [GALLERY=media, {{id}}]{{title|kebab-case}} by {{username}} posted {{date}}[/GALLERY]. This means that we must first map the ids to filenames before we can create Discourse uploads.
  2. The XF uploads are renamed to {{id}}-{{hash}}.{{ext}}. Under the hood XF uses a database table to track the mappings between the original filename and the hash.

I can think of a few different approaches:

  1. use regex to rewrite the media files to links of the form {{original XF domain}}/media/{{id}}/full and enabling the setting in Discourse which makes it download external images #hacky
  2. query the source database for the filename & rename the file before creating the Discourse upload
  3. import the files as they are, and lose the original filenames & get meaningless alt tags

In principle, we could also supply urls instead of local filenames when creating the uploads, but I haven’t checked if it would know to download the files in this case. My guess is it wouldn’t.

Personally, I’m leaning towards option 2, but I’m keen to get input from anyone with more Discourse experience, as I’d like to contribute any improvements back to the repo.