Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
inline_responsive_images
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
inline_responsive_images
Merge requests
!14
Drupal 11 support
Code
Review changes
Check out branch
Download
Patches
Plain diff
Open
Drupal 11 support
issue/inline_responsive_images-3462224:3462224-drupal-11-support
into
4.0.x
Overview
1
Commits
3
Pipelines
5
Changes
6
1 unresolved thread
Hide all comments
Open
Vladimir Roudakov
requested to merge
issue/inline_responsive_images-3462224:3462224-drupal-11-support
into
4.0.x
8 months ago
Overview
1
Commits
3
Pipelines
5
Changes
6
1 unresolved thread
Hide all comments
Expand
0
0
Merge request reports
Compare
4.0.x
version 4
6093a599
6 months ago
version 3
6093a599
6 months ago
version 2
866c7ee5
6 months ago
version 1
96ed06bf
8 months ago
4.0.x (HEAD)
and
latest version
latest version
35433f6c
3 commits,
1 month ago
version 4
6093a599
4 commits,
6 months ago
version 3
6093a599
4 commits,
6 months ago
version 2
866c7ee5
3 commits,
6 months ago
version 1
96ed06bf
1 commit,
8 months ago
6 files
+
29
−
92
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
6
Search (e.g. *.vue) (Ctrl+P)
src/Form/ResponsiveEditorImageDialog.php deleted
100644 → 0
+
0
−
59
Options
<?php
namespace
Drupal\inline_responsive_images\Form
;
use
Drupal\Core\Form\FormStateInterface
;
use
Drupal\Core\Ajax\AjaxResponse
;
use
Drupal\Core\Ajax\HtmlCommand
;
use
Drupal\editor\Ajax\EditorDialogSave
;
use
Drupal\Core\Ajax\CloseModalDialogCommand
;
use
Drupal\editor\Form\EditorImageDialog
;
/**
* Provides an image dialog for CKE4 text editors.
*/
class
ResponsiveEditorImageDialog
extends
EditorImageDialog
{
/**
* {@inheritdoc}
*/
public
function
submitForm
(
array
&
$form
,
FormStateInterface
$form_state
)
{
$response
=
new
AjaxResponse
();
// Convert any uploaded files from the FID values to data-entity-uuid
// attributes and set data-entity-type to 'file'.
$fid
=
$form_state
->
getValue
([
'fid'
,
0
]);
if
(
!
empty
(
$fid
))
{
$file
=
$this
->
fileStorage
->
load
(
$fid
);
$file_url
=
\Drupal
::
service
(
'file_url_generator'
)
->
generateAbsoluteString
(
$file
->
getFileUri
());
// Transform absolute image URLs to relative image URLs: prevent problems
// on multisite set-ups and prevent mixed content errors.
$file_url
=
\Drupal
::
service
(
'file_url_generator'
)
->
transformRelative
(
$file_url
);
$form_state
->
setValue
([
'attributes'
,
'src'
],
$file_url
);
$form_state
->
setValue
([
'attributes'
,
'data-entity-uuid'
],
$file
->
uuid
());
$form_state
->
setValue
([
'attributes'
,
'data-entity-type'
],
'file'
);
}
// When the alt attribute is set to two double quotes, transform it to the
// empty string: two double quotes signify "empty alt attribute". See above.
if
(
trim
(
$form_state
->
getValue
([
'attributes'
,
'alt'
]))
===
'""'
)
{
$form_state
->
setValue
([
'attributes'
,
'alt'
],
''
);
}
if
(
$form_state
->
getErrors
())
{
unset
(
$form
[
'#prefix'
],
$form
[
'#suffix'
]);
$form
[
'status_messages'
]
=
[
'#type'
=>
'status_messages'
,
'#weight'
=>
-
10
,
];
$response
->
addCommand
(
new
HtmlCommand
(
'#editor-image-dialog-form'
,
$form
));
}
else
{
$response
->
addCommand
(
new
EditorDialogSave
(
$form_state
->
getValues
()));
$response
->
addCommand
(
new
CloseModalDialogCommand
());
}
return
$response
;
}
}
Loading