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

Not planned Attachment Handlers & thumbnails

Xon

Well-known member
#1
It would make extending the attachment system vastly easier if the attachment handler participated directly in generating a thumbnail and it's links. Especially if the thumbnail data from xf_attachment_data was moved to xf_attachment.

This would allow for 1 attachment to be attached to multiple pieces of content with different thumbnail policies.
 

Mike

XenForo developer
Staff member
#2
Roughly speaking, the short answer is that approach won't change. It's pretty fundamental to the system at this point. It's also reasonably important that we have content agnostic thumbnails for situations where we do (or situations where we might in the future) be displaying thumbs regardless of content type.

However, in XF2, we have taken steps to allow you to create custom behaviors with attachments more easily, notably the onNewAttachment and onAssociation methods in attachment handlers. These would generally be a point to generate a thumbnail based on your specific needs.
 

ProCom

Well-known member
#3
Great suggestion @Xon, thanks for posting! I've run into dev issues related to this, and it would be great to the attachment handler reworked a bit.
 

Chris D

XenForo developer
Staff member
#4
As Mike said, the attachment handler has been reworked. A lot really.

It’s a lot more flexible now. If you consider all of the additional bits that XFMG does, things like watermarking, custom thumbnails, detecting media needing to be transcoded, storing EXIF data. Aside from general improvements that were already there, a lot of this stuff was added to the attachment handler so that the flexibility was there for add ons like XFMG to be able to do its stuff without the frankly hacky approaches we had to resort to in the past.

I’m confident there’s enough flexibility now to cover most things.
 
#5
We currently have 284,000 attachments on our site with 260,000 unique attachments. The number of duplicates ranges from 1 to 12 or so. They arise from people uploading the same file repeatedly to create attachments. Those stats reflect the current vBulletin usage of the site.

We intend to have much better re-use ability on our XenForo site and will have correspondingly more duplicate attachments. If we cannot get anything to handle the issue invisibly in the data management part, I will probably end up writing a cron job that will go through the database and de-duplicate the attachments on some regular basis. We would like to use the same attachments in multiple content types and as long as the display details are kept with attachment data rather than attachment (use) we will probably need to create an addon to support the multiple content types. I hope that the changes in XF2 will make this approach feasible with a lot less work than it would be with 1.5.