[Week 1] Creating basic media bundles

Hello all!

So the first week of GSoC ends! What a week it was! 😀

In my last blog post, I informed you guys that I will be working on the media module for Drupal 8. In the first week we had three major goals to accomplish:

  • Create a basic media module scaffolding
  • Investigate how “Lightning” distribution uses media_entity and how it solves media problems. Identify if there are any pieces that could be re-used.
  • Create media bundles for image and write suitable tests for it.

So let me tell you about the tasks in detail:

  • Creating media module scaffolding: This is always the easiest part of the module. You just have to define files like .info.yml which contains basic information, .module file which implements methods like hook_help(), .travis.yml file for using Travis CI, a composer.json file which contains project information for composer and a Readme file for the module. You can see the commit for this here

  • Investigating the lightning distribution: So I installed the lightning distribution by Acquia and investigated the way they had used media modules to implement their own lightning media module. A full report can be found here.

  • Creating image media bundle and tests: This is where the interesting part starts. So I created the media bundle for image and added suitable image field to it. I then exported them and included them in the config/install folder so that the media bundle for the image is created as soon as the module is installed. Then I wrote tests to check if the media bundles and the fields are being properly created of not. You can see the entire commit here.

It was an interesting week and I got to learn a lot of new things about Drupal and the way their code is structured. For the following week, I plan to:

  • Create listing of media entities (global media library).
  • Re-create look & feel from file_browser module.

Stay tuned! I’ll post progress about the project next week!

🙂

Leave a comment