Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
uw_cfg_common
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
WCMS
uw_cfg_common
Commits
742bd81b
Commit
742bd81b
authored
3 years ago
by
Eric Bremner
Committed by
Martin Leblanc
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
ISTWCMS-5204: restricting the types of crops on the media upload based on node
parent
470cb444
No related branches found
No related tags found
1 merge request
!180
ISTWCMS-5204: updating node theming to use a free flowing image
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
uw_cfg_common.module
+43
-0
43 additions, 0 deletions
uw_cfg_common.module
with
43 additions
and
0 deletions
uw_cfg_common.module
+
43
−
0
View file @
742bd81b
...
...
@@ -756,6 +756,49 @@ function uw_cfg_common_form_alter(array &$form, FormStateInterface $form_state,
$form
[
'field_uw_meta_tags'
][
'widget'
][
0
][
'twitter_cards'
][
'twitter_cards_page_url'
][
'#access'
]
=
FALSE
;
}
}
// If we are on the media upload form, we want to restrict
// what crops are available.
if
(
$form_id
==
'media_library_add_form_upload'
)
{
// If the crop widget is on the form, unset certain crops.
if
(
isset
(
$form
[
'media'
][
0
][
'fields'
][
'field_media_image'
][
'widget'
][
0
][
'#crop_list'
]))
{
// Get the parameters from the request, this was the only
// way to get out what the bundle was. Since this is a new
// form call from media_library, we could not use get current
// path or uri, since it would only return /media_library.
// The media library parameters has everything listed for the
// node and the node types.
$media_lib_parameters
=
\Drupal
::
request
()
->
query
->
get
(
'media_library_opener_parameters'
);
// If there are media lib parameters, process them.
if
(
$media_lib_parameters
)
{
// If there is a bundle on the parameters, continue
// to process.
if
(
isset
(
$media_lib_parameters
[
'bundle'
]))
{
// If this is a contact, remove all the responsive crops.
// If anything else, remove the portrait crop.
if
(
$media_lib_parameters
[
'bundle'
]
==
'uw_ct_contact'
)
{
foreach
(
$form
[
'media'
][
0
][
'fields'
][
'field_media_image'
][
'widget'
][
0
][
'#crop_list'
]
as
$index
=>
$crop
)
{
if
(
$crop
!==
'uw_crop_portrait'
)
{
unset
(
$form
[
'media'
][
0
][
'fields'
][
'field_media_image'
][
'widget'
][
0
][
'#crop_list'
][
$index
]);
}
}
}
else
{
foreach
(
$form
[
'media'
][
0
][
'fields'
][
'field_media_image'
][
'widget'
][
0
][
'#crop_list'
]
as
$index
=>
$crop
)
{
if
(
$crop
==
'uw_crop_portrait'
)
{
unset
(
$form
[
'media'
][
0
][
'fields'
][
'field_media_image'
][
'widget'
][
0
][
'#crop_list'
][
$index
]);
}
}
}
}
}
}
}
}
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment