Skip to content

Commit

Permalink
tag 8.2.0-alpha.1 (#24)
Browse files Browse the repository at this point in the history
* 8.2.0-alpha.1
  • Loading branch information
pookmish authored and sherakama committed Oct 30, 2019
1 parent ce92e8e commit 10d816f
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 65 deletions.
11 changes: 7 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Stanford Media
8.x-1.0
Release Date: YYYY-MM-DD
# Stanford Media

Initial Release
8.x-2.0-alpha1
--------------------------------------------------------------------------------
_Release Date: 2019-10-30_

- Initial Release using Drupal Core media in 8.8.
- 1.0 release was never made due to its instability and lack of testing coverage.
43 changes: 11 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# [Stanford Media](https://github.com/SU-SWS/stanford_media)
##### Version: 8.x-1.x
##### Version: 8.x-2.x
[![CircleCI](https://circleci.com/gh/SU-SWS/stanford_media.svg?style=svg)](https://circleci.com/gh/SU-SWS/stanford_media)

Maintainers: [pookmish](https://github.com/pookmish)
Expand All @@ -12,40 +12,19 @@ Description
The Stanford Media module is used to enhance the Drupal 8 core media management. The enhancements are listed below.
This has been confirmed to work with ckeditor.

### Entity Browsers

This module provides several different entity browsers:
- Media Browser: All media types
- File Browser: Only file media types
- Image Browser: Only image media types
- video browser: Only video media types.

### Media Field Formatter
A field formatter for any entity reference fields that target media entities. This allows the above entity browsers
to be used on content types. If the target entity is an image, it will allow the rendering to use an image style or a
responsive image style. This helps simplify the display settings of a content type and also eliminates the need for
various joins and relationships in views.
### Field Formatters
In Drupal Core there is no way to select an image style on a media field. The provided field formatters pass in
an image style or responsive image style into the display mode so that a desired image style is easier to display.

### Embed Alter Plugins
When an media entity is being embedded into a wysiwyg, the core media implementation does not provide the user with
certain customizations. The plugins (found in `src/Plugin/MediaEmbedDialog`) target specific media types and uses and
certain customizations. The plugins (found in `src/Plugin/MediaEmbedDialog`) target specific media types and
adds necessary customizations and pre-rendering in order to obtain the desired outcome.

### Entity Browser Plugins
1. Embed Code: Currently this provides the user the ability to input a video url and it will create a video media entity
if the video provider is available.
2. Dropzone Upload: Allows for a drag and drop upload capability. The upload is limited to a single item in WYSIWYG uses
but if using on a field, the upload is limitied to the configured number of items as defined by the field.

### Bulk Upload Page
This uses the above Dropzone Upload plugin. It allows a user to drag and drop as many allowed files as they would like.
It will then provide a form for each item to allow the user to customize image alt texts, item titles, etc.

### Automatic Media Creation
If a content type is using a traditional image field or uses the video embed field without implementing the media
browsers above, upon submission of the form, a media entity will be generated automatically. This allows for reusable
media entities in other areas of the site, such as in the WYSIWYG.

### Media Duplicate Validation
To try to reduce the amount of duplicate images, the media duplicate validation will compare newly uploaded images and
documents and compare them to existing items. If an item is similar enough, the user will be presented with the options
Expand Down Expand Up @@ -84,12 +63,12 @@ placed in the `config/optional` directory, it would cause dependency issues duri
Configuration
---

1. Add the Entity Embed button to the WYSIWYG as needed and check the box "Display embedded entities".
2. It is also suggested to check the box "Linkit URL converter" and place the Linkit converter to process after
displaying the embedded entities.
3. If the WYSIWYG is configured to limit allowed HTML Tags, ensure the the below is added to the list of allowed tags:
`<drupal-entity data-entity-type data-entity-uuid data-entity-embed-display data-entity-embed-display-settings
data-align data-caption data-embed-button class>`
1. Add the Media Library button to the WYSIWYG as needed and check the box "Embed media".
1. If the WYSIWYG is configured to limit allowed HTML Tags, ensure the the below is added to the list of allowed tags:
`<drupal-media data-entity-type data-entity-uuid data-caption data-align data-* class>`
* Although `data-*` would allow all data attributes and you wouldn't need to add any others, the UI form validation will throw an error without the above attributes.
* `data-caption` is only required if captions are allowed. This has to be added and `data-*` cant be relied on due to hard coded checking of the embed form.
* `data-align` is only required if the media can be aligned. Similar issue as `data-align` above.


Troubleshooting
Expand Down
12 changes: 9 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
"description": "Stanford Media module for Drupal 8 Media management",
"type": "drupal-custom-module",
"homepage": "https://github.com/SU-SWS/stanford_media",
"authors": [],
"authors": [
{
"name": "Mike Decker",
"email": "[email protected]",
"role": "Developer"
}
],
"license": "GPL-2.0+",
"minimum-stability": "dev",
"repositories": [
Expand All @@ -15,11 +21,11 @@
"require": {
"davidbarratt/custom-installer": "~1.0",
"drupal/core": "^8.8.0",
"drupal/dropzonejs": "~2.0@alpha",
"drupal/dropzonejs": "^2.0@alpha",
"drupal/entity_usage": "^2.0@beta",
"drupal/inline_entity_form": "^1.0@beta",
"drupal/focal_point": "^1.1",
"drupal/linkit": "~5.0-beta6",
"drupal/linkit": "^5.0-beta6",
"enyo/dropzone": "^5.1"
},
"extra": {
Expand Down
15 changes: 4 additions & 11 deletions src/Form/BulkUpload.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,9 @@ protected function getFiles(array $form, FormStateInterface $form_state) {
$files = [];
}

$form_files = $form_state->getValue(['upload', 'uploaded_files']);
// We do some casting because $form_state->getValue() might return NULL.
foreach ((array) $form_state->getValue([
'upload',
'uploaded_files',
], []) as $file) {
foreach ((array) $form_files as $file) {

// Check if file exists before we create an entity for it.
if (!empty($file['path']) && file_exists($file['path'])) {
Expand All @@ -252,20 +250,15 @@ protected function getFiles(array $form, FormStateInterface $form_state) {

if ($media_type) {
// Validate the media bundle allows for the size of file.
$validators = [
'file_validate_size' => [
$this->bundleSuggestion->getMaxFileSizeBundle($media_type),
0,
],
];
$max_size = $this->bundleSuggestion->getMaxFileSizeBundle($media_type);

// Create the file entity.
$files[] = $this->dropzoneSave->createFile(
$file['path'],
$this->bundleSuggestion->getUploadPath($media_type),
implode(' ', $this->bundleSuggestion->getAllExtensions()),
$this->currentUser,
$validators
['file_validate_size' => [$max_size, 0]]
);
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/Form/MediaLibraryFileUploadForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class MediaLibraryFileUploadForm extends FileUploadForm {
protected $currentUser;

/**
* {@inheritDoc}}
* {@inheritDoc}
*/
public static function create(ContainerInterface $container) {
return new static(
Expand All @@ -57,7 +57,7 @@ public static function create(ContainerInterface $container) {
}

/**
* {@inheritDoc}}
* {@inheritDoc}
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager, MediaLibraryUiBuilder $library_ui_builder, ElementInfoManagerInterface $element_info, RendererInterface $renderer, FileSystemInterface $file_system, DropzoneJsUploadSaveInterface $dropzone_upload, AccountProxyInterface $current_user, OpenerResolverInterface $opener_resolver = NULL) {
parent::__construct($entity_type_manager, $library_ui_builder, $element_info, $renderer, $file_system, $opener_resolver);
Expand Down Expand Up @@ -85,7 +85,7 @@ public static function afterBuildDropzone(array $element, FormStateInterface $fo
}

/**
* {@inheritDoc}}
* {@inheritDoc}
*/
protected function buildInputElement(array $form, FormStateInterface $form_state) {
$element = parent::buildInputElement($form, $form_state);
Expand Down Expand Up @@ -128,7 +128,7 @@ protected function buildInputElement(array $form, FormStateInterface $form_state
}

/**
* {@inheritDoc}}
* {@inheritDoc}
*/
public function updateFormCallback(array &$form, FormStateInterface $form_state) {
if (empty($form_state->getValue(['dropzone', 'uploaded_files']))) {
Expand Down Expand Up @@ -162,15 +162,15 @@ public function uploadDropzoneSubmit(array $form, FormStateInterface $form_state
}

/**
* {@inheritDoc}}
* {@inheritDoc}
*/
public function validateUploadElement(array $element, FormStateInterface $form_state) {
$form_state->setValue('upload', ['fids' => []]);
return parent::validateUploadElement($element, $form_state);
}

/**
* {@inheritDoc}}
* {@inheritDoc}
*/
protected function buildEntityFormElement(MediaInterface $media, array $form, FormStateInterface $form_state, $delta) {
$element = parent::buildEntityFormElement($media, $form, $form_state, $delta);
Expand Down Expand Up @@ -233,7 +233,7 @@ protected function getSimilarMediaOptions(MediaInterface $media) {
}

/**
* {@inheritDoc}}
* {@inheritDoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state) {
$similar_choices = $form_state->getValue('similar_media', []);
Expand Down
6 changes: 3 additions & 3 deletions src/Form/StanfordMediaDialogForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ public static function create(ContainerInterface $container) {
/**
* {@inheritDoc}
*/
public function __construct(EntityRepositoryInterface $entity_repository, EntityDisplayRepositoryInterface $entity_display_repository, MediaEmbedDialogManager $dialog_plugin_manager) {
parent::__construct($entity_repository, $entity_display_repository);
$this->dialogPluginManager = $dialog_plugin_manager;
public function __construct(EntityRepositoryInterface $entity_repository, EntityDisplayRepositoryInterface $display_repository, MediaEmbedDialogManager $dialog_manager) {
parent::__construct($entity_repository, $display_repository);
$this->dialogPluginManager = $dialog_manager;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion stanford_media.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Provides media module configuration and plugins.
core_version_requirement: ^8.8 || ^9
package: media
type: module
version: 8.x-1.x
version: 8.x-2.0-alpha1
dependencies:
- dropzonejs:dropzonejs
- drupal:breakpoint
Expand Down
4 changes: 2 additions & 2 deletions stanford_media.post_update.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ function stanford_media_post_update_8201() {
$settings = $editor->getSettings();
foreach ($settings['toolbar']['rows'] as &$row_items) {
foreach ($row_items as &$row_group) {
if ($media_browser_position = array_search('media_browser', $row_group['items'])) {
$row_group['items'][$media_browser_position] = 'DrupalMediaLibrary';
if ($browser_position = array_search('media_browser', $row_group['items'])) {
$row_group['items'][$browser_position] = 'DrupalMediaLibrary';
$editor->setSettings($settings);
$editor->save();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function testPreRender() {
class TestMediaImageFormatter extends MediaImageFormatter {

/**
* {@inheritDoc}}
* {@inheritDoc}
*/
protected function getStyleOptions() {
return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function testPreRender() {
class TestMediaResponsiveImageFormatter extends MediaResponsiveImageFormatter {

/**
* {@inheritDoc}}
* {@inheritDoc}
*/
public function getStyleOptions() {
return parent::getStyleOptions();
Expand Down

0 comments on commit 10d816f

Please sign in to comment.