A guide to Xenforo attachments / photos

A guide to Xenforo attachments / photos

Walter

Well-known member
Walter submitted a new resource:

A guide to Xenforo attachments / fotos - All about attachments / fotos in Xenforo

Some useful info about attachments/fotos in Xenforo:


Where are attachments stored?
If you were used to vBulletin there was a setting if you want to store the attachments in the file system (doesn't stress your database) or in the database (prohibits synchronization problems if you use several servers).
Xenforo stores them solely in the file system.


How are the files organized?
vBulletin used the userid for the structure of the directories. In Xenforo its slightly different:...

Read more about this resource...
 
Regarding xf_attachment_view, it's a memory-based table used for storing view data. Every time an attachment is viewed, its ID is written to that table (in memory). Then, a cron job run every hour counts the number of times an attachment's ID appears in that table and adds that count to an attachment's view_count.

So, for example, if you have:

31
31
31

The cron job adds 3 to attachment 31's view_count. :)
 
Brilliant resource! My main questions were answered:
  • I only see an upload folder called "0"? A new folder is created every 1,000 images. Cool!
  • How do I balance super large files without frustrating my members? Set a max image dimensions /size so the images will auto-resize!
 
I do have a follow up question: Why are images stored in such a weird way in the DB, e.g., 92-e5135059d8413ce519245f0c7d59ea4e.data

Why aren't images uploaded with native extensions like jpg, gif, etc?
 
Also, related to the above: Say I have a file in my folder called: 92-e5135059d8413ce519245f0c7d59ea4e.data and it is 15 mb in size.
  1. How do I figure out who uploaded the file, if / where it was posted on my forum (thread, resource, etc.)?
  2. How do I determine what type of file it is? A zip, a big picture, a PDF?
 
A quick follow up on these questions:
  1. How do I figure out who uploaded the file, if / where it was posted on my forum (thread, resource, etc.)?
  2. How do I determine what type of file it is? A zip, a big picture, a PDF?
  3. Why are images stored in such a weird way in the DB, e.g., 92-e5135059d8413ce519245f0c7d59ea4e.data vs. being uploaded with native extensions like jpg, gif, etc?
For example, I have a 13mb file in my attachments folder and I have no idea what it is, if it still needs to be there, who uploaded it, etc.

Thanks!
 
A quick follow up on these questions:
  1. How do I figure out who uploaded the file, if / where it was posted on my forum (thread, resource, etc.)?
  2. How do I determine what type of file it is? A zip, a big picture, a PDF?
  3. Why are images stored in such a weird way in the DB, e.g., 92-e5135059d8413ce519245f0c7d59ea4e.data vs. being uploaded with native extensions like jpg, gif, etc?
For example, I have a 13mb file in my attachments folder and I have no idea what it is, if it still needs to be there, who uploaded it, etc.

Thanks!
The first part of the file name, e.g. 92 in the example above is the data ID.

If you perform this query:

Code:
SELECT attachment.*, attachmentdata.*
FROM xf_attachment AS attachment
INNER JOIN xf_attachment_data AS attachmentdata ON
    (attachment.data_id = attachmentdata.data_id)
WHERE attachment.data_id = 92

That will give you all details about the attachment. There's several columns. Including the extension, file size.

The latter part of the filename is the file_hash which you will also see matches up in the database.
 
Thanks Chris, I'll give it a try!

I wonder why each file is renamed like this vs. just maintaining filetype?
 
Important info for photo communities:

The problem:
  • If you set the "Maximum Attachment File Size" too small (e.g. the default 1 MB) your users are frustrated because a typical photo today is larger and they get an error message. Then they either give up or use one of the online picture tools
  • If you use a higher setting (e.g. 10 MB) the users are happy because they can upload all their photos, but now the admin has a problem due to increased disk space usage, increased backup time, increased traffic

The solution:
  • Set the "Maximum Attachment File Size" to something useable (e.g. 10 MB)
  • Set "Maximum Attachment Image Dimensions" to e.g. 800x600 pixels or 1200x1000 pixels
This way the users are able to upload large photos but Xenforo automatically resizes the photo after the upload to the maximum dimension!

An example:

Photo xyz.jpg
File size 4 MB
Original: 2816x2112 = 5.947.392

Maximum set to 1200x1000 = 1.200.000

Photo will be resized to 1200x900 and uses only 350 KB.

Hello Walter i have used your setting from this post.

But i try and upload a 3.2mb 5000x5000pixel photo and it says error the photo you uploaded is to large

please help me thanks
 
Hello Walter i have used your setting from this post.

But i try and upload a 3.2mb 5000x5000pixel photo and it says error the photo you uploaded is to large

please help me thanks
You missed this bit in the guide.

Further settings in config.php:
Config.php contains another interesting setting: $config['maxImageResizePixelCount'] is the maximum size of an image in pixel (width x height) that XenForo will attempt to resize

And from the XenForo manual it linked to

  • $config['maxImageResizePixelCount'] - default: 20000000
    The maximum size of an image (in total numbers of pixels) that XenForo will attempt to resize. Images larger than this will simply not be resized and thus may be rejected. This is calculated using width × height.
As 5000 x 5000 = 25,000,000 it's bigger than the default, so you'll need to increase this value.
 
Top Bottom