extending media presentation
TRANSCRIPT
Extending Media Module
www.wearepropeople.com
Improve your web authors experience
by Alexei Gorobets
www.wearepropeople.com
Long time ago in a galaxy far far away…
www.wearepropeople.com
How do you manage media in Drupal?
www.wearepropeople.com
Administrator • Many modules to use, every module with it’s own features • Complex for new users, no simple solutions • No way to integrate all solutions with WYSIWYG • Training required in most cases • No way to reuse uploaded content
www.wearepropeople.com
Developer • Every module provides it’s own solution for the problem • Many new field typex and many new widgets for the same idea • Tons of modules that implement the same in different aspects • No way to manage your files in cloud (S3, CDN) • No consistent API to extend existing solutions
www.wearepropeople.com
Where is the user is this maze?
www.wearepropeople.com
Let’s be honest…
It’s Wordpress 2.7 released in 2008
www.wearepropeople.com
Let’s be honest…
It’s Drupal 7 in January 2011
www.wearepropeople.com
Here comes Media Module
www.wearepropeople.com
First…
Get use of D7 new Entity API to create File entity
www.wearepropeople.com
Second…
Make file types (Image, File, Video, Text) as entity bundles and they are fieldable
www.wearepropeople.com
More…
• Integrate files in WYSIWYG • Reuse your files by browsing your Library • Use different formatters to display your files • Consistent API to extend for developers • Use StreamWrappers from D7
www.wearepropeople.com
StreamWrappers?
• Use url like s3:// and youtube:// to access remote files • Remote and local files are treated the same way • Easy way to add new wrappers
www.wearepropeople.com
Looks better?
www.wearepropeople.com
Insert into WYSIWYG
www.wearepropeople.com
Upload new or select from library
www.wearepropeople.com
Select a formatter
www.wearepropeople.com
Image inserted
www.wearepropeople.com
How it’s handled behind the scenes
www.wearepropeople.com
Every tab is a plugin. Create your own!
www.wearepropeople.com
Different file types!
www.wearepropeople.com
Fieldable file types!
www.wearepropeople.com
But! Most valuable is the API!
www.wearepropeople.com
Create your Media Browser from Views
www.wearepropeople.com
Create your Media Browser from Views
www.wearepropeople.com
or create a class…
www.wearepropeople.com
For example:
www.wearepropeople.com
Meet hook_media_browser_plugins_alter().
www.wearepropeople.com
Add upload forms for each media browser
www.wearepropeople.com
Add upload forms for each media browser
www.wearepropeople.com
What else? Back to Wordpress!
www.wearepropeople.com
We want to edit file attributes on file upload
• Set a proper file name • Assign OG audience to the file • Set other usefull attributes
www.wearepropeople.com
Let’s alter the forms
Set our submit callback instead of default
www.wearepropeople.com
Let’s alter the forms
Set redirects using media-popup setting in query
www.wearepropeople.com
Let’s alter the forms Alter file attributes form, remove fields, make Cancel button work!
www.wearepropeople.com
Let’s go for a demo!
www.wearepropeople.com
Questions?
www.wearepropeople.com
Thanks!