Back to top anchor
Documentation

Improvements to the media management in June 2020

We are updating our documentation library to be ready for the Sector 10! Find out more in our Sector 10 roadmap or head straight to our collection of Sector 10 - Changes and Updates.

User role
All user roles
Task
Content editing Sitebuilding
Topic
Media management
Product
Sector Starter kit

From June 2020, it will be much easier to keep track of your media assets in the media management! A media usage count allows editorial users to see how many times media is used, and where, while error messages around deleting and deleted files are improved. Sitebuilders can also delete files from the file system directly via the AdminUI. 

The changes will be available to all Sector sites built on Sector 5.0.0-rc3, but can also be retrofitted to older sites. 

Not sure what the media file manager does? 

Head over to our Introduction to the media file management!

Media usage

Media management without a link to where the media entities are used is ... suboptimal. The media management allows editorial users to manage media assets, and information about media usage is a must-have.

Changes and improvements 

The entity usage module allows us to add a usage column to the media manager (/admin/content/media). The usage count is linked to a list of entities and a Sector patch shows more specifically where assets are used - for example as a banner or embedded in the WYSIWYG editor. 

Usage count a bit high? 

The media usage count includes revisions. Assets are counted for each usage in published content, drafts, and revisions. 

Deleting media assets

In Sector Drupal 8+ our expectation is that media assets (files, images, local videos) are deleted from the file system after the parent media entity is deleted.

One reason why we use media is to allow editorial teams the ability to take control of their files in the public file system. Outdated or wrongly uploaded files need to be deleted from the file system in a safe and secure manner.

When Drupal 8 was released this was the case, but Drupal 8.4. introduced a default setting that prevented files being automatically deleted following a series of critical bugs with the "file usage" tracking: files wrongly set to have >0 uses were deleted even though they were in use. However, these issues occur around translation, or where files are uploaded to a site without a parent media entity. In out-of-the-box Sector, we upload all files using media. 

Changes 

With Sector 5.0.0-rc3, we opt-in to file deletion by changing 'make_unused_managed_files_temporary' in the Sector `file.settings` yml config to `TRUE` and by setting 'temporary_maximum_age' to '3600'. 

This marks a media asset as temporary after a media entity is deleted and the garbage collection will delete the asset on the next cron run, with a one hour buffer.

Using Sector for multilingual sites? 

If you are using Sector for multilingual sites, we recommend to keep an eye on the issues raised  and decide if you want to change the setting again to opt-out.

Improving error messages 

In most use cases, it is better to remove media embeds before a media entity is deleted, so we now display an extended error message to users when a media entity is deleted that is still used on the site - the message is linked to the usage screen. 

In Drupal, when a media entity has been deleted that was still in use, an error is displayed - this error is visible to the public which is again... suboptimal. With a little tweak we now display this message only to logged in users! 

Deleting files from the file system 

In some cases, orphan files (files without a media entity wrapper) might remain in the file system. For editorial users without the Drupal administrator user role, these files are 'invisible' - the files are no longer listed in the media management and are only visible in the file administration (/content/files). Sitebuilders (Drupal administrators) can see the files and the file usage count, but - out of the box - they are not able to delete files from the file system using the AdminUI. 

We looked into a few options, and decided that in this case we don't want to fall back on the temporary marker and the garbage collection, but want the file gone immediately - so the files can now be deleted via a VBO from the file administration tab. 

Media File system Entity usage

Last updated

Sector 10 is coming!

Find out more in our Sector 10 roadmap.

Need Help?

Sector is brought to you by Sparks Interactive - supporting Sector from Wellington and Auckland

Open Source award winner!

Sparks Interactive are delighted to accept the Open Source Use in Business award for Sector and the Sector.nz open source platform.

Subscribe for Sector updates