Follow along with http://davereid.github.io/portland2013-core-convo

About me

  • Senior Engineer at Palantir.net
  • Twitter: @davereid
  • IRC: davereid
  • Maintain almost 2% of contrib modules
    • Pathauto, Media, Redirect, Token, etc.
  • Core subsystem maintainer
  • Two adorable cats
  • New dad as of Oct 15, 2012

class FileManagement
implements /Drupal/Core/UnofficialInitiative*

*Note I am not a PSR-0 expert.

What is the initiative?

What were our goals?

What were our goals?

  • Configurable file types
  • Guided file upload
  • HTML5 file upload
  • File access API
  • File metadata API
  • Improved accessiblity with alt/title fields
  • HTML5 for audio/video
  • Improved support for remote files
  • Fix assumptions/data from file/image fields

Goals: Configurable file types

File entity: DONE!; Core: Merge in D9

Goals: Wizard file upload

File entity: DONE!; Core: Merge in D9

Goals: HTML5 file upload

File entity: In progress; Core: In progress

Goals: File access API

File entity: 90%; Core: 75%

file_entity_access('view', $file, $account);

function hook_file_entity_access($op, $file, $account) {
  $type = is_string($file) ? $file : $file->type;

  if ($op !== 'create' && (REQUEST_TIME - $file->timestamp) < 3600) {
    // If the file was uploaded in the last hour, deny access to it.
    return FILE_ENTITY_ACCESS_DENY;
  }

  // Returning nothing from this function would have the same effect.
  return FILE_ENTITY_ACCESS_IGNORE;
}

function hook_query_file_entity_access_alter(QueryAlterableInterface $query) {
  // Only show files that have been uploaded more than an hour ago.
  $query->condition('timestamp', REQUEST_TIME - 3600, '<=');
}

Goals: File metadata API

File entity: In progress; Core: D8?

Non-editable data in key/value storage. Remove metadata from field storage.

Image dimensions example:

// Before
$file->image_dimensions['width'] = 300;
$file->image_dimensions['height'] = 200;

// After
$file->data['width'] = 300;
$file->data['height'] = 200;

hook_file_metadata_info() {
  $info['width']  = array('label' => t('Width'));
  $info['height'] = array('label' => t('Height'));
  return $info;
}

Goals: Improved accessiblity with alt/title fields

File entity: 90%; Core: Merge in D9

Goals: HTML5 for audio/video

File entity: In progress; Core: Merge in D9

  • Plan to support simple <audio> and <video> for file fields.
  • Support multiple <track> elements with field cardinatlity.

Goals: Improved support for remote files

Core: DONE!

  • \Drupal\Core\StreamWrapper\ReadOnlyStream
  • \Drupal\Core\StreamWrapper\LocalReadOnlyStream
  • Nice to have: system stream wrappers:
    • module://views/css/file.css
    • theme://admin/js/admin.js
    • profile://default/css/default.css

Goals: Fix assumptions/data from file/image fields

Core: In progress

Why did we not accomplish our goals?

Why did we not accomplish our goals?

  • Lead had a baby
  • Resources
  • Meetings

Can we still accomplish what we wanted to from contrib for Drupal 8?

Drupal 8 todos

  • Metadata API in D8 core.
  • Finish file entity in D8 contrib.
  • Polish and revamp Media browser UI.

What are our plans to improve things in Drupal 9?

Drupal 9 todos

  • Merge file entity into core's file module - EARLY.
  • Merge media into core???

WE NEED HELP!

When can you help?

  • Code sprints
    • Friday, May 24, 2013
      DrupalCon Portland
    • Sunday, Aug 11, 2013
      DrupalCorn, Iowa City, Iowa
  • Next Thursday 20:00 UTC IRC meeting in #drupal-media
  • ANYTIME!