This repository has been archived by the owner on Nov 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #2784699 by phenaproxima: Provide option for resizing inline im…
…ages
- Loading branch information
Showing
38 changed files
with
647 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
modules/lightning_features/lightning_media/config/install/lightning_media.settings.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
entity_embed: | ||
choose_display: false |
12 changes: 12 additions & 0 deletions
12
modules/lightning_features/lightning_media/config/schema/lightning_media.schema.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
modules/lightning_features/lightning_media/lightning_media.links.task.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
lightning_media.settings: | ||
route_name: lightning_media.settings | ||
title: 'Media' | ||
base_route: lightning_core.settings |
7 changes: 7 additions & 0 deletions
7
modules/lightning_features/lightning_media/lightning_media.routing.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
lightning_media.settings: | ||
path: '/admin/config/system/lightning/media' | ||
defaults: | ||
_title: Lightning | ||
_form: '\Drupal\lightning_media\Form\SettingsForm' | ||
requirements: | ||
_is_administrator: 'true' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
modules/lightning_features/lightning_media/src/Form/EntityEmbedDialog.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
namespace Drupal\lightning_media\Form; | ||
|
||
use Drupal\Core\Form\FormStateInterface; | ||
use Drupal\entity_embed\Form\EntityEmbedDialog as BaseEntityEmbedDialog; | ||
use Drupal\media_entity\MediaInterface; | ||
|
||
class EntityEmbedDialog extends BaseEntityEmbedDialog { | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function buildEmbedStep(array $form, FormStateInterface $form_state) { | ||
$entity = $form_state->get('entity'); | ||
$element = $form_state->get('entity_element'); | ||
$input = $form_state->getUserInput(); | ||
|
||
// If we're working with an existing embed, $input['editor_object'] will be | ||
// set, in which case we don't want to change anything (see ::buildForm()). | ||
// Otherwise, if the entity being embedded is a media item, see if its type | ||
// plugin has a preference regarding which display plugin to use. | ||
if (empty($input['editor_object']) && $entity instanceof MediaInterface) { | ||
$plugin_definition = $entity->getType()->getPluginDefinition(); | ||
|
||
if (isset($plugin_definition['entity_embed_display'])) { | ||
$element['data-entity-embed-display'] = $plugin_definition['entity_embed_display']; | ||
$form_state->set('entity_element', $element); | ||
} | ||
} | ||
|
||
$form = parent::buildEmbedStep($form, $form_state); | ||
|
||
// If the user can choose the display plugin, allow Lightning Media's | ||
// settings to override that access. | ||
$element = &$form['attributes']['data-entity-embed-display']; | ||
if ($element['#access']) { | ||
$element['#access'] = $this->config('lightning_media.settings')->get('entity_embed.choose_display'); | ||
} | ||
return $form; | ||
} | ||
|
||
} |
50 changes: 50 additions & 0 deletions
50
modules/lightning_features/lightning_media/src/Form/SettingsForm.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
namespace Drupal\lightning_media\Form; | ||
|
||
use Drupal\Core\Form\ConfigFormBase; | ||
use Drupal\Core\Form\FormStateInterface; | ||
|
||
/** | ||
* The settings form for controlling Lightning Media's behavior. | ||
*/ | ||
class SettingsForm extends ConfigFormBase { | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function getEditableConfigNames() { | ||
return ['lightning_media.settings']; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getFormId() { | ||
return 'lightning_media_settings_form'; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function buildForm(array $form, FormStateInterface $form_state) { | ||
$form['choose_display'] = [ | ||
'#type' => 'checkbox', | ||
'#title' => $this->t('Allow users to choose how to display embedded media'), | ||
'#default_value' => $this->config('lightning_media.settings')->get('entity_embed.choose_display'), | ||
]; | ||
return parent::buildForm($form, $form_state); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function submitForm(array &$form, FormStateInterface $form_state) { | ||
$this->config('lightning_media.settings') | ||
->set('entity_embed.choose_display', (bool) $form_state->getValue('choose_display')) | ||
->save(); | ||
|
||
parent::submitForm($form, $form_state); | ||
} | ||
|
||
} |
Oops, something went wrong.