-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Work on #1491. #783
Work on #1491. #783
Conversation
Bumping @Islandora/8-x-committers on this PR. @manez had approved the PR this one replaces (which I created against the wrong branch). |
Hey @mjordan this seems like a sound thing to do but I think injecting JS might be a bit heavy handed. I think we can implement Example code:
|
@jordandukart thanks for the review and suggestion, I hadn't thought of that approach. I'll be away from my computer until next week but will try this then. |
No worries, if you need to chat about anything ping me here or in Slack! |
@jordandukart I've incorporated your suggestion. Thanks! |
Travis failed on this:
But I ran @Islandora/8-x-committers why's that? |
Will try to get back to this today @mjordan! |
islandora.module
Outdated
function islandora_add_default_image_alt_text($element, $form_state, $form) { | ||
if ($element['alt']['#access']) { | ||
$params = \Drupal::request()->query->all(); | ||
if (count($params) > 0 && array_key_exists('edit', $params)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bit of a nit but you could just do an isset($params['edit'])
or similarly this could be re-written as:
if ($edit_param = \Drupal::request()->query->get('edit')) {
$media_of_nid = $edit_param['field_media_of']['widget'][0]['target_id'];
$node = \Drupal::entityTypeManager()->getStorage('node')->load($media_of_nid);
if ($node) {
$element['alt']['#default_value'] = $node->getTitle();
}
}
Not something that would stop me from approving this but just a code style thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, I've replaced if (count($params) > 0 && array_key_exists('edit', $params)) {
with the much more concise if (isset($params['edit'])) {
, but I'll keep the others.
Thanks again for the thorough review!
Looks good to me @mjordan! |
@Islandora/8-x-committers now that this has been reviewed, tested, and approved, can haz merge? |
Note: This PR replaces #777.
Github Issue: Islandora/documentation#1491
What does this Pull Request do?
Provides default values for the media name field, and for Image media, a default value for the Alt text field.
What's new?
Implementation of
hook_form_alter()
to populate the media name field, and an implementation ofhook_field_widget_WIDGET_TYPE_form_alter()
to populate the image Alt text field.How should this be tested?
drush cr
)Additional Notes:
Interested parties
@Islandora/8-x-committers