Skip to content
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

Issue #3494511: Profile image display twice on the post album page #4259

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions modules/social_features/social_album/social_album.module
Original file line number Diff line number Diff line change
Expand Up @@ -353,33 +353,6 @@ function social_album_form_comment_form_alter(&$form, FormStateInterface $form_s
}
}

/**
* Implements hook_form_FORM_ID_alter().
*/
function social_album_form_post_form_alter(&$form, FormStateInterface $form_state, $form_id) {
if (\Drupal::routeMatch()->getRouteName() === 'social_album.post') {
if (isset($form['current_user_image'])) {
unset($form['current_user_image']);
}
}
elseif (isset($form['field_album'])) {
// Hide album select field when feature is disabled on the image post form.
$status = \Drupal::config('social_album.settings')->get('status');
if (!$status) {
unset($form['field_album']);
}
else {
$form['field_album']['#states'] = [
'visible' => [
':input[name="field_post_image[0][fids]"]' => [
'filled' => TRUE,
],
],
];
}
}
}

/**
* Implements hook_form_FORM_ID_alter().
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php

namespace Drupal\social_album\Hooks;

use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\hux\Attribute\Alter;

/**
* Replace hook: social_album_form_post_form_alter.
*
* @package Drupal\social_album\Hooks
*/
final class SocialAlbumFormHooks {

/**
* The current route match.
*/
protected RouteMatchInterface $routeMatch;

/**
* The config factory service.
*/
protected ConfigFactoryInterface $configFactory;

/**
* Constructor.
*
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
* The current route match.
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The config factory service.
*/
public function __construct(
RouteMatchInterface $route_match,
ConfigFactoryInterface $config_factory
) {
$this->routeMatch = $route_match;
$this->configFactory = $config_factory;
}

/**
* Form alter hook: replacement of social_album_form_post_form_alter.
*
* @param array $form
* The drupal form.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The form state.
*/
#[Alter('form_post_form')]
public function formPostFormAlter(array &$form, FormStateInterface $form_state): void {
if ($this->routeMatch->getRouteName() === 'social_album.post') {
if (isset($form['current_user_image'])) {
unset($form['current_user_image']);
}
}
elseif (isset($form['field_album'])) {
// Hide album select field when feature is disabled on image post form.
$status = $this->configFactory->get('social_album.settings')->get('status');
if (!$status) {
unset($form['field_album']);
}
else {
$form['field_album']['#states'] = [
'visible' => [
':input[name="field_post_image[0][fids]"]' => [
'filled' => TRUE,
],
],
];
}
}
}

}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@
width: 100%;
}

.field--widget-social-post-album-image {
.form-managed-file {
.form-submit {
top: -11px;
right: 11px;
left: auto;
}
}
}

.table-responsive + .image-widget:not(.hidden) {
position: absolute;
display: block;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class SocialPostAlbumManagedFile extends ManagedFile {
*/
public static function uploadAjaxCallback(&$form, FormStateInterface &$form_state, Request $request) {
$response = parent::uploadAjaxCallback($form, $form_state, $request);
$element_parents = \Drupal::request()->request->get('element_parents');
$element_parents = \Drupal::request()->query->get('element_parents');
// Either has a parent, or null if no parent, both are fine but can be
// bool|float|int|string.
if (!is_string($element_parents)) {
Expand Down
15 changes: 0 additions & 15 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3118,21 +3118,6 @@ parameters:
count: 1
path: modules/social_features/social_album/social_album.module

-
message: "#^Function social_album_form_post_form_alter\\(\\) has no return type specified\\.$#"
count: 1
path: modules/social_features/social_album/social_album.module

-
message: "#^Function social_album_form_post_form_alter\\(\\) has parameter \\$form with no type specified\\.$#"
count: 1
path: modules/social_features/social_album/social_album.module

-
message: "#^Function social_album_form_post_form_alter\\(\\) has parameter \\$form_id with no type specified\\.$#"
count: 1
path: modules/social_features/social_album/social_album.module

-
message: "#^Function social_album_form_social_post_entity_form_alter\\(\\) has no return type specified\\.$#"
count: 1
Expand Down
Loading