Hi all,
Recently I wrote a Discourse theme component (GitHub - Beholder-Vision/discourse-insert-model-3d: A Discourse theme component for adding 3D models to topics) that allows Discourse admins to enable the upload and display of 3D models to their forums.
Things seemed to work well at first until I got a report that some uploaded models had disappeared, and then checking my own forum I saw that the uploaded assets (3D models and poster images) had been purged too Insert Model 3D - #2 by patrickemin.
Reading the docs (Understanding Uploads, Images, and Attachments), I had assumed that the uploaded assets would be ok because they were referenced by a post, but after doing some digging, I found this code, discourse/app/models/post.rb at 03bb43f7468d3aa6e73bba0805193ae50c7ec2d5 · discourse/discourse · GitHub that appears to be doing the work of identifying uploads on the server. From what I can make out, an uploaded file is only counted as being referenced by a post if it is referenced by one of a limited number of HTML tags. So a linked upload will be recognised if referenced by the href attribute of a <a> element but not if it’s referenced by the src attribute of a <model-viewer> element (which is what my new theme component adds in).
Can someone who is familiar with that code please confirm if my understanding here is correct or not? If that is correct then I think that people creating theme components can mark assets as uploads by generating a hidden <a> link that references the asset, but it would be really useful if the docs (Understanding Uploads, Images, and Attachments) could be updated to highlight this gotcha.
Many thanks
Alan