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

UHF-10239: Adds image gallery paragraph #840

Merged
merged 26 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3abd014
UHF-10239: Adds image gallery paragraph
Nov 7, 2024
48a23b4
UHF-10239: Enables module, adds it to page templates
Nov 8, 2024
0d39f69
UHF-10239: Fixed function name
Nov 8, 2024
edfc071
UHF-10239: Fixed filenames
annadruid Nov 8, 2024
38d7d14
UHF-10239: Removed unnecessary photographer config
annadruid Nov 8, 2024
5e6f7a0
UHF-10239: Fixed linter errors
annadruid Nov 11, 2024
5464de8
UHF-10239: Fixed linter errors
annadruid Nov 11, 2024
1f5a9c1
UHF-10239: Config changes and return stype fix
annadruid Nov 11, 2024
b4a4d61
UHF-10239: Return type fix
annadruid Nov 11, 2024
1ea9e26
UHF-10239: Adds image styles and moved language configs to correct place
annadruid Nov 12, 2024
ce64ad1
UHF-10239: Added validation for image gallery
annadruid Nov 13, 2024
f8bb546
UHF-10239: Fixed image dependecy
annadruid Nov 13, 2024
075e5b4
UHF-10239: Fixed image dependecy
annadruid Nov 14, 2024
e0e4355
UHF-10239: Added update function to re-import helfi_media configs
annadruid Nov 14, 2024
302819b
UHF-10239: Added update function to re-import hefi_image_styles configs
annadruid Nov 14, 2024
dcbba9d
UHF-10239: Fixed config
annadruid Nov 14, 2024
2758fe6
UHF-10239: Fixed langcodes and added missing config
annadruid Nov 14, 2024
b77ae44
UHF-10239: Fixed linter errors
annadruid Nov 14, 2024
0412b5b
UHF-10239: Added translations for error message
annadruid Nov 14, 2024
25207a1
UHF-10239: Merge branch 'main' into UHF-10239
annadruid Nov 14, 2024
6305837
UHF-10239: Renamed configs and fixed configs that uses them
annadruid Nov 14, 2024
1af3955
UHF-10239: Coding standard fixes
annadruid Nov 15, 2024
494a025
UHF-10239: Added image gallery to unit and service pages
annadruid Nov 15, 2024
c6b2ed9
UHF-10239: Adjusted new image styles based on pr comments
annadruid Nov 18, 2024
fc83507
UHF-10239: Added example image of the image gallery paragraph.
khalima Nov 18, 2024
9b076df
UHF-10239: Fixed 2:3 image styles
annadruid Nov 18, 2024
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
8 changes: 8 additions & 0 deletions modules/hdbt_admin_tools/hdbt_admin_tools.module
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,14 @@ function hdbt_admin_tools_entity_bundle_field_info_alter(&$fields, EntityTypeInt
) {
$fields['field_has_hero']->addConstraint('Hero', []);
}

if ($entity_type->id() === 'paragraph' && $bundle == 'image_gallery') {
// Add constraint to check if image gallery has two gallery items.
if (array_key_exists('field_gallery_item', $fields)) {
$fields['field_gallery_item']->addConstraint('ImageGallery', []);
}
}

}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

tuutti marked this conversation as resolved.
Show resolved Hide resolved
namespace Drupal\hdbt_admin_tools\Plugin\Validation\Constraint;

use Symfony\Component\Validator\Constraint;

/**
* Checks that the image gallery has at least two items.
*
* @Constraint(
* id = "ImageGallery",
* label = @Translation("There should be at least two gallery items.", context = "Validation"),
* type = "entity:paragraph"
* )
*/
class ImageGalleryConstraint extends Constraint {

/**
* Message shown for the Image gallery paragraph.
*
* @var string
*/
public string $galleryItemRequired = 'Image gallery paragraph should have at least two items.';

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
tuutti marked this conversation as resolved.
Show resolved Hide resolved

namespace Drupal\hdbt_admin_tools\Plugin\Validation\Constraint;

use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;

/**
* Validates the Image Gallery constraint.
*/
class ImageGalleryConstraintValidator extends ConstraintValidator {

/**
* {@inheritdoc}
*/
public function validate(mixed $value, Constraint $constraint) {
tuutti marked this conversation as resolved.
Show resolved Hide resolved
assert($constraint instanceof ImageGalleryConstraint);
$parent = $value->getEntity();

if ($value->getName() !== 'field_gallery_item') {
return;
}

if (
$parent &&
$parent->hasField('field_gallery_item') &&
$parent->get('field_gallery_item')->count() < 2
) {
$this->context->addViolation($constraint->galleryItemRequired);
}
}

}
6 changes: 6 additions & 0 deletions modules/hdbt_admin_tools/translations/fi.po
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,9 @@ msgstr "Tekstialue (merkkimäärälaskuri)"

msgid "Textfield (character counter)"
msgstr "Tekstikenttä (merkkimäärälaskuri)"

msgid "Image gallery paragraph should have at least two items."
msgstr "Kuvagalleriassa tulisi olla vähintään kaksi kuvaa."

msgid "Image is mandatory with the selected Hero design."
msgstr "Kuva on pakollinen valitun designin kanssa."
6 changes: 6 additions & 0 deletions modules/hdbt_admin_tools/translations/sv.po
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,9 @@ msgstr "Uppdatera användarlösenord"

msgid "Hero paragraph is mandatory if the Hero checkbox has been selected. Either unselect the checkbox or create the hero paragraph by clicking the Add Hero button."
msgstr "Hero paragraph är obligatoriskt om kryssrutan Hero har markerats. Avmarkera antingen kryssrutan eller skapa hero paragraph genom att klicka på knappen Lägg till Hero"

msgid "Image gallery paragraph should have at least two items."
msgstr "Det bör finnas minst två bilder i bildgalleriet"

msgid "Image is mandatory with the selected Hero design."
msgstr "Bild är obligatorisk med den valda Hero-designen."
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
uuid: 74ef3c22-d7ea-4cb1-8aab-01ba6b79bde5
langcode: en
status: true
dependencies:
module:
- focal_point
- image_style_quality
name: 0.7_1080w_1620h_LQ
label: 0.7_1080w_1620h_LQ
effects:
1c1da0f4-bb6a-4f11-88eb-8cd33a8e0da2:
uuid: 1c1da0f4-bb6a-4f11-88eb-8cd33a8e0da2
id: focal_point_scale_and_crop
weight: 1
data:
width: 1080
height: 1620
crop_type: focal_point
c319bca0-92f7-4467-a5ec-1b902ce2be1b:
uuid: c319bca0-92f7-4467-a5ec-1b902ce2be1b
id: image_style_quality
weight: 2
data:
quality: 65
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
uuid: 9ec716c1-6f6d-4d08-971f-a9d9230e43b7
langcode: en
status: true
dependencies:
module:
- focal_point
name: 0.7_400w_600h
label: 0.7_400w_600h
effects:
dc8a6ee8-839c-4972-9eb8-5df5305dc75d:
uuid: dc8a6ee8-839c-4972-9eb8-5df5305dc75d
id: focal_point_scale_and_crop
weight: 1
data:
width: 400
height: 600
crop_type: focal_point
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
uuid: f0276d08-9181-4923-9b87-49e9bf5ee5f4
langcode: en
status: true
dependencies:
module:
- focal_point
name: 0.7_450w_675h
label: 0.7_450w_675h
effects:
11ff7a5b-af0b-4eac-a4a3-7bc3b9ac6188:
uuid: 11ff7a5b-af0b-4eac-a4a3-7bc3b9ac6188
id: focal_point_scale_and_crop
weight: 1
data:
width: 450
height: 675
crop_type: focal_point
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
uuid: 6ff8a4a5-849c-4f94-8f22-1eb670793bdc
langcode: en
status: true
dependencies:
module:
- focal_point
name: 0.7_540w_810h
label: 0.7_540w_810h
effects:
6535b34f-21c8-4005-8561-d1936245e319:
uuid: 6535b34f-21c8-4005-8561-d1936245e319
id: focal_point_scale_and_crop
weight: 1
data:
width: 540
height: 810
crop_type: focal_point
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
uuid: 5ebc2957-c7ca-4606-ba96-49486e6630e4
langcode: en
status: true
dependencies:
module:
- focal_point
- image_style_quality
name: 0.7_800w_1200h_LQ
label: 0.7_800w_1200h_LQ
effects:
fb181588-37f9-4269-ae4e-7c93d76ffebe:
uuid: fb181588-37f9-4269-ae4e-7c93d76ffebe
id: focal_point_scale_and_crop
weight: 1
data:
width: 800
height: 1200
crop_type: focal_point
a3284e2a-d636-4454-b7b6-3958d1db2b35:
uuid: a3284e2a-d636-4454-b7b6-3958d1db2b35
id: image_style_quality
weight: 2
data:
quality: 65
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
uuid: 19aa2c22-c3e9-47cd-b767-9fca520ae4ba
langcode: en
status: true
dependencies:
module:
- focal_point
- image_style_quality
name: 0.7_900w_1350h_LQ
label: 0.7_900w_1350h_LQ
effects:
289822b3-1d38-43a4-a18e-0344b4ef9161:
uuid: 289822b3-1d38-43a4-a18e-0344b4ef9161
id: focal_point_scale_and_crop
weight: 1
data:
width: 900
height: 1350
crop_type: focal_point
c5118eb7-9ad5-4756-9515-d6358c38bd75:
uuid: c5118eb7-9ad5-4756-9515-d6358c38bd75
id: image_style_quality
weight: 2
data:
quality: 65
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
uuid: 9f76056d-d05c-40e9-9455-9caf237c2229
langcode: en
status: true
dependencies:
module:
- focal_point
- image_style_quality
name: 1_1108w_1108h_LQ
label: 1_1108w_1108h_LQ
effects:
3fe5b5a5-6dcd-4410-865d-22d39e20ae22:
uuid: 3fe5b5a5-6dcd-4410-865d-22d39e20ae22
id: focal_point_scale_and_crop
weight: 1
data:
width: 1108
height: 1108
crop_type: focal_point
348c0fc5-7317-49a8-9a52-934e77165825:
uuid: 348c0fc5-7317-49a8-9a52-934e77165825
id: image_style_quality
weight: 2
data:
quality: 65
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
uuid: 0f96fcb7-856c-4d80-9a22-b1e88f44ca2b
langcode: en
status: true
dependencies:
module:
- focal_point
name: 1_440w_440h
label: 1_440w_440h
effects:
9ef8198f-6739-4a26-b0d7-157e42648cc4:
uuid: 9ef8198f-6739-4a26-b0d7-157e42648cc4
id: focal_point_scale_and_crop
weight: 1
data:
width: 440
height: 440
crop_type: focal_point
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
uuid: ca8cb2c4-7e3c-4a4a-ae75-9520f628f369
langcode: en
status: true
dependencies:
module:
- focal_point
name: 1_554w_554h
label: 1_554w_554h
effects:
ed62a58f-6f7b-47ff-b8c9-3574fb9abeba:
uuid: ed62a58f-6f7b-47ff-b8c9-3574fb9abeba
id: focal_point_scale_and_crop
weight: 1
data:
width: 554
height: 554
crop_type: focal_point
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
uuid: d0a56f46-9d91-47a8-9269-57fda40b75ed
langcode: en
status: true
dependencies:
module:
- focal_point
- image_style_quality
name: 1_880w_880h_LQ
label: 1_880w_880h_LQ
effects:
c4554106-234a-4d04-a6cf-c7ae4f8886dd:
uuid: c4554106-234a-4d04-a6cf-c7ae4f8886dd
id: focal_point_scale_and_crop
weight: 1
data:
width: 880
height: 880
crop_type: focal_point
ee011418-cb33-48a5-af34-10bfac5b3e64:
uuid: ee011418-cb33-48a5-af34-10bfac5b3e64
id: image_style_quality
weight: 2
data:
quality: 65
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
uuid: c0fef26d-9cc5-4756-b247-5a9c3f7b4550
langcode: en
status: true
dependencies:
config:
- image.style.1_1108w_1108h_LQ
- image.style.1_277w_277h
- image.style.1_406w_406h
- image.style.1_440w_440h
- image.style.1_554w_554h
- image.style.1_554w_554h_LQ
- image.style.1_812w_812h_LQ
- image.style.1_880w_880h_LQ
module:
- helfi_image_styles
id: image_gallery_1_1
label: 'Image gallery 1:1'
image_style_mappings:
-
image_mapping_type: image_style
image_mapping: 1_406w_406h
breakpoint_id: helfi_image_styles.xl
multiplier: 1x
-
image_mapping_type: image_style
image_mapping: 1_812w_812h_LQ
breakpoint_id: helfi_image_styles.xl
multiplier: 2x
-
image_mapping_type: image_style
image_mapping: 1_406w_406h
breakpoint_id: helfi_image_styles.l
multiplier: 1x
-
image_mapping_type: image_style
image_mapping: 1_812w_812h_LQ
breakpoint_id: helfi_image_styles.l
multiplier: 2x
-
image_mapping_type: image_style
image_mapping: 1_440w_440h
breakpoint_id: helfi_image_styles.m
multiplier: 1x
-
image_mapping_type: image_style
image_mapping: 1_880w_880h_LQ
breakpoint_id: helfi_image_styles.m
multiplier: 2x
-
image_mapping_type: image_style
image_mapping: 1_277w_277h
breakpoint_id: helfi_image_styles.s
multiplier: 1x
-
image_mapping_type: image_style
image_mapping: 1_554w_554h_LQ
breakpoint_id: helfi_image_styles.s
multiplier: 2x
-
image_mapping_type: image_style
image_mapping: 1_554w_554h
breakpoint_id: helfi_image_styles.xs
multiplier: 1x
-
image_mapping_type: image_style
image_mapping: 1_1108w_1108h_LQ
breakpoint_id: helfi_image_styles.xs
multiplier: 2x
breakpoint_group: helfi_image_styles
fallback_image_style: 1_406w_406h
Loading