Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Drupal 7 Media modules


Published on

Drupal 7 Media modules: Media, Media Gallery, etc.
by Grigory Naumovets
(A presentation at DrupalCafé, Kiev, Feb. 23, 2012)

Drupal 7 Media modules

  1. 1. Drupal 7 Media Modules (Media, Media Gallery, etc.) Grigory NAUMOVETS Kiev, Ukraine
  2. 2. Outline <ul><li>[why] Do we need more modules to manage media? </li></ul><ul><li>Media module: </li></ul><ul><ul><li>features, advantages, problems </li></ul></ul><ul><ul><li>1.x and 2.x branches </li></ul></ul><ul><li>Media Gallery module: </li></ul><ul><ul><li>features, advantages, problems </li></ul></ul><ul><li>Other media-related modules: MediaElement, Media Browser Plus, MediaFront </li></ul><ul><li>Conclusions </li></ul>
  3. 3. Site content <ul><li>Text content </li></ul><ul><ul><li>Nodes </li></ul></ul><ul><ul><li>Comments </li></ul></ul><ul><ul><li>Blocks </li></ul></ul><ul><ul><li>Views </li></ul></ul><ul><ul><li>etc. </li></ul></ul><ul><li>Media (file) content </li></ul><ul><ul><li>Managed files (have their own File ID in the system) </li></ul></ul><ul><ul><li>Unmanaged files (are not known to the system – just linked from somewhere) </li></ul></ul>
  4. 4. Managed files in Drupal 7 <ul><li>Drupal 7 has database tables ‘ file_managed ’ and ‘ file_usage ’ keeping track of managed files: file ID, name, URI, size, type, user and module responsible for this file, etc. </li></ul><ul><li>But there is no user interface to manage these ‘managed files’! </li></ul>
  5. 5. [Text] Content administration <ul><li>/admin/content – [node] content administration </li></ul><ul><li>Also, we can administer comments, blocks, views, etc… </li></ul>but how can we administer MEDIA???
  6. 6. Filefield <- media file <ul><li>Regular File upload widget: How can we use one file in many nodes? We can only duplicate it – WTF??? </li></ul><ul><li>We want to: </li></ul><ul><ul><li>Re-use one file in many fields </li></ul></ul><ul><ul><li>Organize media (tags, directories, etc.) </li></ul></ul>
  7. 7. List of f ile u ploading and m anaging modules <ul><li> </li></ul><ul><li>Database File manager, FileDepot, File Framework, Filemanager, File maintenance, WebFM, Upload paths, Filefield paths, etc. etc. etc. </li></ul><ul><li>Many of these are obsolete/abandoned/rarely used </li></ul><ul><li>No full-featured solution yet </li></ul>
  8. 8. Media module <ul><li>Available only for Drupal 7 </li></ul><ul><li>Reported installs: >39,000 (Feb. 2012) </li></ul><ul><li>Branches: </li></ul><ul><ul><li>7.x-1.x – recommended (features freezed, bugfixes only) </li></ul></ul><ul><ul><li>7.x-2.x – unstable (with new improvements) </li></ul></ul><ul><li>Requirements: </li></ul><ul><ul><li>Javascript must be enabled </li></ul></ul><ul><ul><li>CTools </li></ul></ul><ul><ul><li>Media 7.x-2.x relies on Views and File entity (fieldable files); 7.x-1.x has File entity included inside </li></ul></ul><ul><li>Media module development was sponsored by: Acquia, Advomatic, and </li></ul>
  9. 9. Installing Media module… Now we have: <ul><li>New field type: Multimedia asset </li></ul>New widget: Media File Selector Media Library
  10. 10. We also have… Content types »… » Manage display New display formatter: Media
  11. 11. File display format should be defined for the appropriate file type (“bundle”) – Image, Audio, Video, Other <ul><li>/admin/config/media/file-types </li></ul>
  12. 12. Configuring file display for each file type admin/config/media/file-types/manage/video/file-display File view modes – ‘Default’, ‘Link’, ‘Preview’, ‘Small’, ‘Large’, ‘Original’, etc.; you need to save settings separately for each mode Display precedence order is important – e.g. when you need to display videos from YouTube, ‘YouTube Video’ display should go before ‘MediaElement Video’ etc.
  13. 13. Media Library: now media content can be managed like node content <ul><li>/admin/content – Node content administration </li></ul><ul><li>/admin/content/media – Media content administration </li></ul>new tab for Media administration
  14. 14. Media administration <ul><li>/admin/content/media </li></ul>We can choose LIST view or THUMBNAIL view
  15. 15. Media items in the list have their own URLs and can be viewed/edited like nodes <ul><li>/media/45/edit edit Media item </li></ul>/media/45 view Media item
  16. 16. Viewing Media items like nodes /media/[fid] Media item URL [fid] is File ID from ‘file_managed’ table
  17. 17. So, Media module does not create a ‘Media Library’ table in the database <ul><li>It uses the tables that Drupal 7 already has: ‘file_managed’ and ‘file_usage’ </li></ul><ul><li>But it adds new fields to define new properties of media files: ‘Title’ and ‘Description’ field_data_media_title, field_data_media_description field_revision_media_title, field_revision_media_description </li></ul>
  18. 18. Editing Media items ‘ Title ’ and ‘ Description ’ of items in Media Library are DIFFERENT from ‘ Title ’ and ‘ Alternate text ’ properties of images in Image field and ‘ Description ’ property of files in File field They are NOT shown when displaying images or file attachments in the usual way Modules displaying media should be able to handle media titles and descriptions (e.g. Media Gallery)
  19. 19. Under the hood: Media title and description <ul><li>These are different values kept in different database tables than ‘File description’ and ‘Image title’ properties available for File/Image fields </li></ul>
  20. 20. Adding files to Media Library via Upload <ul><li>With Plupload plugin, we can upload multiple files by drag-n-dropping them here </li></ul>
  21. 21. Adding media from web <ul><li>hhh </li></ul>via media_vimeo.module via media_youtube.module <ul><li>With some additional modules, we can add to the Media Library media from YouTube, Vimeo, and other supported providers </li></ul>
  22. 22. Adding media from Remote URL <ul><li>Remote stream wrapper module: now we can add remote media to the Media Library without copying the files to our server </li></ul>via remote_stream_wrapper.module
  23. 23. Importing files to Media Library from another directory <ul><li>In this way, we can import files bigger than maximum size allowed for PHP upload (upload files by FTP to some directory, then import to Media Library) </li></ul>
  24. 24. Using media from Media Library in File/Image fields <ul><li>Now we have a new widget type: Media file selector </li></ul>
  25. 25. Media file selector widget <ul><li>Selecting media from Library </li></ul>
  26. 26. However, some things are missing… With regular Image widget, we have “ Alternate text ” and “ Title ” that we can display near/over the image
  27. 27. What we see with the regular Image widget Image Title displayed in a lightbox view
  28. 28. With Media File selector widget <ul><li>We can edit ‘ Title ’ and ‘ Description ’ of this item in Media Library, but we cannot display them in the same way as we display “Alternate text” and “Title” image properties </li></ul><ul><li>It’s really a disappointment    </li></ul><ul><li>Same problem with ‘ File description ’ for File fields    </li></ul>“ Alternate text ” and “ Title ” image properties are no longer available. WTF???
  29. 29. Referencing media from Library inline in textarea fields <ul><li>TinyMCE, CKEditor: enable ‘Media browser’ plugin or add ‘Media’ button </li></ul>File display modes (Configuration » Media » File types » Manage file display)
  30. 30. Media input filter should be enabled to convert media tags into markup <ul><li>Media tags look like that: </li></ul><ul><li>[[{&quot;type&quot;:&quot;media&quot;,&quot;view_mode&quot;:&quot;media_preview&quot;,&quot;fid&quot;:&quot;44&quot;,&quot;attributes&quot;:{&quot;alt&quot;:&quot;&quot;,&quot;class&quot;:&quot;media-image&quot;,&quot;height&quot;:&quot;180&quot;,&quot;typeof&quot;:&quot;foaf:Image&quot;,&quot;width&quot;:&quot;180&quot;}}]] </li></ul>
  31. 31. Removing media from a node <ul><li>Removing a media file from a node does not delete it from the Media Library </li></ul>
  32. 32. Removing files from Media Library <ul><li>… /admin/content/media </li></ul><ul><li>You cannot delete a media file which is in use somewhere until you remove it from all the nodes </li></ul><ul><li>Sometimes it’s kind of frustrating… </li></ul>
  33. 33. Media Gallery module <ul><li>Depends on Media module </li></ul><ul><li>Understands ‘Title’ and ‘Description’ attributes of media files </li></ul><ul><li>Can display images and videos in the same gallery </li></ul><ul><li>Developed by the engineering team at Acquia </li></ul>
  34. 34. Viewing all galleries
  35. 35. We can have images and videos in the same gallery Media Title displayed on hover These are videos
  36. 36. Images and videos can be displayed inline or in a pop-up colorbox <ul><li>Media Gallery can display both Title and Description of media items </li></ul><ul><li>Media Gallery calls Colorbox library independently of Colorbox module </li></ul><ul><li>Integration with Colorbox module (to use its features and settings) requires some patching </li></ul>
  37. 37. It’s easy to add, reorder, and edit media in the gallery Edit or Remove Reorder items by dragging the handle to a new position Add media with Media File selector
  38. 38. Editing gallery settings <ul><li>It’s easy to set for each specific gallery the number of rows and columns, media display inline or in a pop-up box, etc. </li></ul>
  39. 39. Displaying LOCAL video files (not from YouTube, Vimeo, etc.) <ul><li>For this, you may need to install and configure some media player - e.g. MediaElement player (Drupal module integrating MediaElement.js library) </li></ul><ul><li>May not work in a pop-up box </li></ul>
  40. 40. Configuring file display settings for Video admin/config/media/file-types/ manage/video/file-display
  41. 41. Media Gallery problems: Theme-dependent <ul><li>Theme-dependent problems (e.g. for Adaptivetheme and related themes) </li></ul><ul><ul><li>Broken display of “All Galleries” page (may need some css tweaking) </li></ul></ul><ul><ul><li>Drag handles not displayed: how can you reorder items now? (may need some patching) </li></ul></ul>
  42. 42. Media Gallery problems: Colorbox <ul><li>Colorbox-related problems: </li></ul><ul><ul><li>Clicking on the colorbox (not on the arrows) does not work as expected: it leads to “View Detail page” instead of showing the next item in the gallery (may need some css patching) </li></ul></ul><ul><ul><li>Media Gallery work with Colorbox directly; integration with Colorbox module (to use all its features and settings) may require some patching </li></ul></ul>
  43. 43. Media Gallery problems: Taxonomy <ul><li>Strange things with Taxonomy: </li></ul><ul><ul><li>Media Gallery creates ‘Gallery collections’ vocabulary with ‘Galleries’ term in it, but they are not visible and not editable in admin/structure/taxonomy interface </li></ul></ul><ul><li>Conflicts with i18n_taxonomy reported </li></ul>
  44. 44. So, Media Gallery still needs some <ul><li>File tools </li></ul>
  45. 45. … more than you could expect from a module creating quite a lot of tables in the database
  46. 46. Problems with Media <ul><li>Organize Media (with lots of items in Media Library, you need to structurize it somehow via folders, tags, etc. – like you do with your boomarks or email) </li></ul><ul><li>Handling media attributes (Media’s ‘Title’ and ‘Description’ vs Image’s “Title’ and “Alt text’ and File’s ‘Description’) </li></ul>
  47. 47. Media Browser Plus module <ul><li>Works with Media 7.x-1.x and 7.x-2.x branches </li></ul><ul><li>UI and functional improvements (multiple selection, media search, etc.) </li></ul><ul><li>Organizing Media: folders, tags, etc. </li></ul>
  48. 48. Media 7.x-2.x branch <ul><li>‘ Media’ is now called ‘Files’: /admin/content/file instead of /admin/content/media </li></ul>
  49. 49. Media 7.x-2.x branch: core File field instead of Media field <ul><li>And it’s not just name change: now we are supposed to work with the core File field instead of ‘Multimedia asset’ fields (which are deprecated) </li></ul>
  50. 50. Media 7.x-2.x branch <ul><li>One more change: Integration with Views . Now we have ‘View Library’ selection mode </li></ul>
  51. 51. Media 7.x-2.x branch <ul><li>And this ‘MediaBrowser’ view is editable </li></ul>
  52. 52. MediaFront module <ul><li>Integration of OSM media player </li></ul><ul><li>Plays both local and remote (YouTube, Vimeo, etc.) video </li></ul><ul><li>Integration with Views: can create video galleries displayed as playlists in media player’s window </li></ul><ul><li>Detailed video tutorial: </li></ul>
  53. 53. MediaFront: a video gallery displayed as a playlist
  54. 54. How to re-use files in file fields without Media File selector? <ul><li>FileField Sources module/widget </li></ul>
  55. 55. References <ul><li>James Gollan’s presentation </li></ul><ul><li>Drupalcon Chicago presentation </li></ul>
  56. 56. Questions? <ul><li>Contact info: </li></ul><ul><ul><li> </li></ul></ul><ul><ul><li>[email_address] </li></ul></ul>