- Compatible XF 2.x versions
- 2.3
- Additional requirements
- XenForo 2.3 or later.
The XenForo Media Gallery is an add-on that allows you and your users to create galleries of images, videos, and audio in your forum, organized into admin-defined categories or user-created albums.
Media categories
Media will be placed into individual categories that are organized into a tree. In this regard, they are very similar to the node tree.
A category may be one of three types:
- Container only: these categories will not contain media or albums, instead serving to organize sub-categories.
- Albums only: in these categories, users will create albums that can contain one or more media items. When the category is viewed, there will be one entry for each album.
- Media items only: media will be added directly to these categories and not organized into albums. Each media item will be displayed directly when viewing the category.
Media fields
Custom media fields allow you to define additional structured fields for users to fill in when creating a thread.
Media fields can be displayed in one of several locations:
Below media item: this will be displayed in the box below the media, with the title and author info.
Bottom of media info block: in the sidebar opposite the comments, in the media information block.
Extra info block: in the sidebar opposite the comments, in a new Extra information block.
New sidebar block: in its own sidebar block, using the custom field's name as the header.
Permissions
The Media Gallery adds a number of new permissions. When installed, reasonable defaults are selected based on existing permissions. However, you should confirm that the permissions meet your needs and that your moderators have the permissions you want.
Options
The Media Gallery's options can be found in the XenForo media gallery option group.
What's new in XenForo Media Gallery 2.3?
Our primary focus for XenForo Media Gallery 2.3 is performance. Now, the Media Gallery is performant for most use cases, but there's an upper limit in terms of the size of your gallery which can determine just how performant it is. The queries that Media Gallery executes to return media items in various contexts are necessarily complex. We have to take into account a variety of different states including general permissions, category permissions, album privacy settings and individual media and album states.Over the years we have added features which can mitigate the issues to an extent including the ability to limit the media lists to a maximum time period, for example, only displaying the most recent 12 months of media items.
Aside from the general complexity of the unit of work each query does, one of the biggest performance degradations is caused by MySQL's handling of large offsets. In a recent test consisting of over 45,000 pages of media (1 million media items!) trying to load page 45,252 resulted in an over 30 second delay to load the page.
Deferred joins
Enter "deferred joins"! This is actually a new feature in the core of XenForo, albeit currently only used within Media Gallery. For the developers amongst you, all it really means is you will call$finder->fetchDeferred() rather than $finder->fetch(), and for the non-developers amongst you, what it means is "slow query go fast" Behind the scenes what actually happens is rather than executing a single query, it executes two! Which may seem counter-intuitive but bear with me. The first query simply aims to fetch the applicable IDs for the conditions and page you are on which is fast because it uses the primary key, whereas the second query fetches all of the data applicable with all of the joins but matching those specific IDs fetched from the first query.
To cut a very long story short, if you take the page 45,252 example from above, this same query reduced from over 30 seconds to only 2 seconds. While 2 seconds might still seem a little on the high side, this is a 93% decrease from before, and it's only as high as it is because of the high page number. The upshot is that the sheer majority of those 45,000+ pages will now be remarkably faster to load than before. This will not only massively decrease frustration of your users, but it will significantly increase the likelihood of these pages being crawled by search engines and dramatically decrease the load on your database.