james gollan d.o: gollyg twitter: gollyg. overview files in drupal 7 the media suite of modules site...
TRANSCRIPT
James Golland.o: gollygtwitter: gollyg
QuickTime™ and aDVCPRO - PAL decompressor
are needed to see this picture.
Overview
• Files in Drupal 7
• The media suite of modules
• Site recipe: Adding media to your site
QuickTime™ and aH.264 decompressor
are needed to see this picture.
Files in Drupal 7
Drupal 7 - File entities
• Files in Drupal 7 are handled as entities
• Files are attached using a file field (or an image field)
• This creates an entity reference to the file
Managed vs unmanaged files
• The File API provides functionality for working with files
• Files can be 'managed' or 'unmanaged'
• Managed files have a corresponding entry in the 'file_managed' table
• Operations on managed files update this table
• Unmanaged files are not 'known' to Drupal, and cannot be referenced or re-used (except via raw links)
Stream wrappers
• A stream is simply a resource object
• Drupal stream wrappers are an extension of PHP's stream wrapper functionality
• Stream wrappers are referred to using a standard pattern:
scheme://target
• core stream wrappers include:
• public://
• private://
• temp://
• PHP also provides a number of stream wrappers
File usage
• Drupal 7 tracks file usage, and will lock a file that is currently in use by making an entry in the 'file_usage' table
• "In use" means that it is referenced from a node
• This prevents accidental file deletion, and allows for better file management
That's all great, but...
• File entities are NOT field-able
• File entities are not easily re-usable
• There is no interface for managing file entities
• enter...
The Media module
Media Module
“Media's aim is to solve Drupal's long standing media handling problem.”
“The framework provided by the Media module is helping to unify many of the current multimedia and file efforts, acting as a springboard to future development.”http://drupal.org/documentation/modules/media
Current state
Media currently has 2 main branches:•7.x-1.x (currently at RC3)•7.x-2.x (currently unstable)
•dependency on file_entity module...
File entity module
• Makes files field-able. (Yay)!
• Makes files re-usable. (Yay * 2)!
• Provides an administrative interface for files on the system
• Provides a UI for managing file display modes
File_entity module (cont.)
• Defines 6 file_entity bundles, based upon common MIME types:
• video
• image
• audio
• text
• application
• other
• Places files into one of the above bundles, based upon file extension
Media module
• Provides a unified and extensible widget for handling file uploads
• Provides a formatter for displaying file_entities of any type
• Provides various api functions for integrating with core file handling, file styles, stream wrappers, and making the whole system pluggable with extra file providers
Site recipe: Adding media to your site
Setup
• Use the following modules:
• Media (7.x-2.x branch)
• mediaelement (mediaelement 7.x-1.x-dev)
• libraries
• media_youtube
• ckeditor (the library, not the module)
• wysiwyg
• file_element
Setup
• Oh, and this patch :-|
• http://drupal.org/node/1141374
• and this extra little bit of code...
• https://gist.github.com/1124045
Configure the node bundle
• Add a file field to a content type
• Select the 'media' formatter
• From the node display page, set the file field display configuration to ‘Media’ and choose an appropriate view mode for the field display
Configure the file display
• Visit the file management screen.
• From the ‘Manage file display’ link, assign the correct formatters for the file. Note that you can assign more than one formatter to a file - the first applicable formatter will be applied.
• Change the display on the node type to refer to the correct display mode.
Adding metadata
• Visit the file management screen.
• From the ‘Manage fields’ link. Add any fields that you want on the file bundle.
• Change the display on the node type to refer to the correct display mode.
Configure input formats and CKeditor
• Download CKeditor to libraries folder
• Add media filter
• Add button to CKeditor
• Enable correct input format
Drawbacks
• File access still not implemented
• Files inserted via the WYSISYG are not inserted into the file_usage table, meaning that accidental deletion is possible, and there is no easy way of auditing these files
• No option to add meta-data when uploading a file
• Browsing a large number of files in the widget difficult
• Many functions and features still a *bit* fragile (currently over 100 open bugs)
Find out more•http://drupal.org/media•http://drupal.org/mediaelement•http://drupal.org/documentation/modules/media•irc: #drupal-media
QuickTime™ and a decompressor
are needed to see this picture.