[Week 11] Finishing Embedding and Fixing UI
Hello All!
I mentioned in my introduction blog post about the media module for Drupal 8 on which I was working on with Janez Urevc (slashrsm) and Tadej Baša (paranojik) under Google Summer Of Code 2016.
This is the last week of GSoC and the submissions start from next week. The journey so far has been amazing and we are almost ready to release the module on Drupal.org official modules repository. The main focus this week was to polish the main features of the module to make the module easier to use. Let me go over the issues we fixed this week:
1) Last week, I wrote about how I modified the hook_install() code to automatically enable the embedding functionality when the media module is installed. It made it simpler for the users to embed content without having to modify the editor settings and filters. But we found that it didn’t work with the Drupal sites which have custom editors. So I had to modify the code to enable the embed button for all the formats which have WYSIWYG editors.
Here is how it looks now
// Enable the media embed button and modify filters.
$filter_formats = \Drupal::entityTypeManager()->getStorage('filter_format')->loadByProperties(array('status' => TRUE));
foreach ($filter_formats as $filter_format) {
$editor = Editor::load($filter_format->getOriginalId());
if ($editor) {
// Make the changes to editor and filters only if editor type exists.
$editor_settings = $editor->getSettings();
$editor_settings['toolbar']['rows'][0][3]['items'][] = 'media';
$editor->setSettings($editor_settings);
$editor->save();
$format = $editor->getFilterFormat();
if ($format->filters('filter_html')->settings['allowed_html']) {
$format->filters('filter_html')->settings['allowed_html'] .= '<drupal-entity data-entity-type data-entity-uuid data-view-mode data-entity-embed-display data-entity-embed-display-settings data-align data-caption data-embed-button>';
}
$format->setFilterConfig('entity_embed', ['status' => 1]);
$format->setFilterConfig('filter_html_image_secure', ['status' => 0]);
$format->save();
}
}
2) There were a lot of UI improvements which were required in the module. I fixed most of them last week and got it merged this week. Here is the link to the Pull request. The patch removed some irrelevant fields from Entity View Display. Also the patch had fixes for few file icons.
3) Media items in the media library did not have the url to the media item in the title. I opened a pull request which enables the link to the media in the title. The fix was really simple and all that had to be done was set link_to_entity to True in media bundle view display. There are a couple of small alterations which still need to be done and should be done soon.
4) Modifying Gallery Bundle tests. Last week there were some updates to the media entity modules. It required me to modify the test code in our module to make it compatible to the latest code.
One major feature which is still needed in the media module is cropping functionality. I have started to work on the functionality and should be ready by this weekend. I am really excited about everyone using the media module starting next week!
I’ll write a detailed post about the module next week when we release the module for general public.
:)