Skip to content

Commit

Permalink
HPC-9191: Make changes to the cropping UI, wording, remove obsolete f…
Browse files Browse the repository at this point in the history
…ields
  • Loading branch information
berliner committed Nov 15, 2023
1 parent 97b2683 commit 263212f
Show file tree
Hide file tree
Showing 28 changed files with 73 additions and 168 deletions.
3 changes: 3 additions & 0 deletions composer.patches.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
"drupal/google_tag": {
"Issue #3250315: Error during cache rebuild when assets are stored on NFS": "https://www.drupal.org/files/issues/2022-11-23/3250315-google-tag-nfs-locks-5.patch"
},
"drupal/image_widget_crop": {
"Issue #3401986: The containers summary text should not be overwritten": "https://www.drupal.org/files/issues/2023-11-15/3401986-2.patch"
},
"drupal/page_manager": {
"Issue #3176661: Allow to edit page title when using Layout Builder variant": "https://www.drupal.org/files/issues/2022-11-15/page_manager-lb-title-3176661-15.patch"
},
Expand Down
9 changes: 0 additions & 9 deletions config/core.entity_form_display.node.article.default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ dependencies:
config:
- field.field.node.article.field_base_objects
- field.field.node.article.field_chapter
- field.field.node.article.field_crop_hero_image
- field.field.node.article.field_display_hero_image
- field.field.node.article.field_image
- field.field.node.article.field_inherit_section_image
Expand Down Expand Up @@ -78,7 +77,6 @@ third_party_settings:
group_display:
children:
- field_display_hero_image
- field_crop_hero_image
- image_crop
- field_inherit_section_image
label: Display
Expand Down Expand Up @@ -125,13 +123,6 @@ content:
size: 60
placeholder: ''
third_party_settings: { }
field_crop_hero_image:
type: boolean_checkbox
weight: 28
region: content
settings:
display_label: true
third_party_settings: { }
field_display_hero_image:
type: boolean_checkbox
weight: 27
Expand Down
9 changes: 0 additions & 9 deletions config/core.entity_form_display.node.document.default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ status: true
dependencies:
config:
- field.field.node.document.field_base_objects
- field.field.node.document.field_crop_hero_image
- field.field.node.document.field_display_hero_image
- field.field.node.document.field_image
- field.field.node.document.field_inherit_section_image
Expand Down Expand Up @@ -43,7 +42,6 @@ third_party_settings:
group_display:
children:
- field_display_hero_image
- field_crop_hero_image
- image_crop
- field_inherit_section_image
label: Display
Expand Down Expand Up @@ -115,13 +113,6 @@ content:
disable_drag_and_drop: 0
wrapper: 0
third_party_settings: { }
field_crop_hero_image:
type: boolean_checkbox
weight: 16
region: content
settings:
display_label: true
third_party_settings: { }
field_display_hero_image:
type: boolean_checkbox
weight: 15
Expand Down
2 changes: 0 additions & 2 deletions config/core.entity_view_display.node.article.card.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ dependencies:
- core.entity_view_mode.node.card
- field.field.node.article.field_base_objects
- field.field.node.article.field_chapter
- field.field.node.article.field_crop_hero_image
- field.field.node.article.field_display_hero_image
- field.field.node.article.field_image
- field.field.node.article.field_inherit_section_image
Expand Down Expand Up @@ -90,7 +89,6 @@ content:
hidden:
field_base_objects: true
field_chapter: true
field_crop_hero_image: true
field_display_hero_image: true
field_inherit_section_image: true
field_remote_article: true
Expand Down
2 changes: 0 additions & 2 deletions config/core.entity_view_display.node.article.card_summary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ dependencies:
- core.entity_view_mode.node.card_summary
- field.field.node.article.field_base_objects
- field.field.node.article.field_chapter
- field.field.node.article.field_crop_hero_image
- field.field.node.article.field_display_hero_image
- field.field.node.article.field_image
- field.field.node.article.field_inherit_section_image
Expand Down Expand Up @@ -104,7 +103,6 @@ content:
hidden:
field_base_objects: true
field_chapter: true
field_crop_hero_image: true
field_display_hero_image: true
field_inherit_section_image: true
field_remote_article: true
Expand Down
11 changes: 0 additions & 11 deletions config/core.entity_view_display.node.article.default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ dependencies:
config:
- field.field.node.article.field_base_objects
- field.field.node.article.field_chapter
- field.field.node.article.field_crop_hero_image
- field.field.node.article.field_display_hero_image
- field.field.node.article.field_image
- field.field.node.article.field_inherit_section_image
Expand Down Expand Up @@ -111,16 +110,6 @@ content:
third_party_settings: { }
weight: 7
region: content
field_crop_hero_image:
type: boolean
label: above
settings:
format: default
format_custom_false: ''
format_custom_true: ''
third_party_settings: { }
weight: 9
region: content
field_display_hero_image:
type: boolean
label: above
Expand Down
2 changes: 0 additions & 2 deletions config/core.entity_view_display.node.article.grid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ dependencies:
- core.entity_view_mode.node.grid
- field.field.node.article.field_base_objects
- field.field.node.article.field_chapter
- field.field.node.article.field_crop_hero_image
- field.field.node.article.field_display_hero_image
- field.field.node.article.field_image
- field.field.node.article.field_inherit_section_image
Expand Down Expand Up @@ -105,7 +104,6 @@ content:
region: content
hidden:
field_base_objects: true
field_crop_hero_image: true
field_display_hero_image: true
field_inherit_section_image: true
field_remote_article: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ dependencies:
- core.entity_view_mode.node.search_result
- field.field.node.article.field_base_objects
- field.field.node.article.field_chapter
- field.field.node.article.field_crop_hero_image
- field.field.node.article.field_display_hero_image
- field.field.node.article.field_image
- field.field.node.article.field_inherit_section_image
Expand Down Expand Up @@ -117,7 +116,6 @@ content:
hidden:
field_base_objects: true
field_chapter: true
field_crop_hero_image: true
field_display_hero_image: true
field_inherit_section_image: true
field_remote_article: true
Expand Down
2 changes: 0 additions & 2 deletions config/core.entity_view_display.node.article.teaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ dependencies:
- core.entity_view_mode.node.teaser
- field.field.node.article.field_base_objects
- field.field.node.article.field_chapter
- field.field.node.article.field_crop_hero_image
- field.field.node.article.field_display_hero_image
- field.field.node.article.field_image
- field.field.node.article.field_inherit_section_image
Expand Down Expand Up @@ -47,7 +46,6 @@ content:
hidden:
field_base_objects: true
field_chapter: true
field_crop_hero_image: true
field_display_hero_image: true
field_inherit_section_image: true
field_remote_article: true
Expand Down
11 changes: 0 additions & 11 deletions config/core.entity_view_display.node.document.default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ status: true
dependencies:
config:
- field.field.node.document.field_base_objects
- field.field.node.document.field_crop_hero_image
- field.field.node.document.field_display_hero_image
- field.field.node.document.field_image
- field.field.node.document.field_inherit_section_image
Expand Down Expand Up @@ -101,16 +100,6 @@ content:
third_party_settings: { }
weight: 110
region: content
field_crop_hero_image:
type: boolean
label: above
settings:
format: default
format_custom_false: ''
format_custom_true: ''
third_party_settings: { }
weight: 114
region: content
field_display_hero_image:
type: boolean
label: above
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ dependencies:
config:
- core.entity_view_mode.node.search_result
- field.field.node.document.field_base_objects
- field.field.node.document.field_crop_hero_image
- field.field.node.document.field_display_hero_image
- field.field.node.document.field_image
- field.field.node.document.field_inherit_section_image
Expand Down Expand Up @@ -104,7 +103,6 @@ content:
region: content
hidden:
field_base_objects: true
field_crop_hero_image: true
field_display_hero_image: true
field_inherit_section_image: true
field_remote_document: true
Expand Down
2 changes: 0 additions & 2 deletions config/core.entity_view_display.node.document.teaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ dependencies:
config:
- core.entity_view_mode.node.teaser
- field.field.node.document.field_base_objects
- field.field.node.document.field_crop_hero_image
- field.field.node.document.field_display_hero_image
- field.field.node.document.field_image
- field.field.node.document.field_inherit_section_image
Expand All @@ -29,7 +28,6 @@ content:
region: content
hidden:
field_base_objects: true
field_crop_hero_image: true
field_display_hero_image: true
field_image: true
field_inherit_section_image: true
Expand Down
2 changes: 1 addition & 1 deletion config/crop.type.14x5.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ uuid: 14c68939-0df4-4319-b4c6-14c3d62e9763
langcode: en
status: true
dependencies: { }
label: 14x5
label: 'On page (14x5)'
id: 14x5
description: 'Letterbox size for hero images'
aspect_ratio: '14:5'
Expand Down
2 changes: 1 addition & 1 deletion config/crop.type.16x9.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ uuid: 0990d642-014f-438c-8f6a-e13c90907019
langcode: en
status: true
dependencies: { }
label: 16x9
label: 'In links (16x9)'
id: 16x9
description: 'Card size for galleries'
aspect_ratio: '16:9'
Expand Down
23 changes: 0 additions & 23 deletions config/field.field.node.article.field_crop_hero_image.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ field_name: field_display_hero_image
entity_type: node
bundle: article
label: 'Display hero image'
description: 'Display a hero image on the top of the article page.'
description: 'Display a hero image on the top of the article page and when showing links to the article page.'
required: false
translatable: false
default_value:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ field_name: field_inherit_section_image
entity_type: node
bundle: article
label: 'Inherit document image'
description: 'If checked and this article is displayed as a subpage of a document, the hero image will be taken from the document instead of the article.'
description: "If checked and this article is displayed as a subpage of a document, the hero image on the article page will be taken from the document instead of the article. Links to the article will continue to use the article's own image if available."
required: false
translatable: true
default_value:
-
value: 1
value: 0
default_value_callback: ''
settings:
on_label: 'On'
Expand Down
23 changes: 0 additions & 23 deletions config/field.field.node.document.field_crop_hero_image.yml

This file was deleted.

18 changes: 0 additions & 18 deletions config/field.storage.node.field_crop_hero_image.yml

This file was deleted.

23 changes: 17 additions & 6 deletions html/modules/custom/ghi_content/ghi_content.module
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@

use Drupal\Core\Batch\BatchBuilder;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Entity\Entity\EntityViewDisplay;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Link;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\Url;
use Drupal\file\Plugin\Field\FieldType\FileFieldItemList;
use Drupal\ghi_content\Controller\MigrationBatchController;
use Drupal\ghi_content\Entity\Article;
use Drupal\ghi_content\Entity\ContentBase;
Expand Down Expand Up @@ -284,12 +286,7 @@ function ghi_content_preprocess_page(&$variables) {
return;
}

$crop_image = TRUE;
if ($image_node instanceof ContentBase) {
$crop_image = $image_node->shouldCropHeroImage();
}

$image_style_name = $crop_image ? 'hero' : 'hero_not_cropped';
$image_style_name = 'hero';

// Go through some trouble to show a responsive image here.
$repsonsive_image_style_id = $image_style_name;
Expand Down Expand Up @@ -380,6 +377,20 @@ function ghi_content_preprocess_node(&$variables) {
];
}

if ($node instanceof ContentBase && !$node->shouldDisplayHeroImage()) {
// If the article is configured to hide the image, hide it everywhere.
/** @var \Drupal\Core\Entity\Entity\EntityViewDisplay $view_mode_entity */
$view_mode_entity = EntityViewDisplay::load('node.article.' . $variables['view_mode']);
/** @var \Drupal\file\Plugin\Field\FieldType\FileFieldItemList $items */
$items = $node->field_image;
if ($view_mode_entity && $items instanceof FileFieldItemList) {
$items->filter(function ($item) {
return FALSE;
});
$variables['content']['field_image'] = $view_mode_entity->getRenderer('field_image')->view($items);
}
}

if ($node instanceof Document) {
$variables['document_summary'] = $node->getSummary();
}
Expand Down
Loading

0 comments on commit 263212f

Please sign in to comment.