Skip to content

Commit

Permalink
Merge pull request #344 from AmazeeLabs/SLB-385-focalpoint-waku
Browse files Browse the repository at this point in the history
SLB-385: focalpoint in waku
  • Loading branch information
pmelab authored Sep 17, 2024
2 parents f58eb34 + fccf7c0 commit 3342876
Show file tree
Hide file tree
Showing 23 changed files with 1,835 additions and 2,316 deletions.
1 change: 1 addition & 0 deletions apps/cms/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"drupal/entity_usage": "^2.0@beta",
"drupal/environment_indicator": "^4.0.14",
"drupal/field_group": "^3.4",
"drupal/focal_point": "^2.1",
"drupal/honeypot": "^2.1.2",
"drupal/key_auth": "^2.1",
"drupal/lagoon_logs": "^2.1.1",
Expand Down
148 changes: 135 additions & 13 deletions apps/cms/composer.lock

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 @@ -4,10 +4,10 @@ status: true
dependencies:
config:
- field.field.media.image.field_media_image
- image.style.thumbnail
- image.style.large
- media.type.image
module:
- image
- focal_point
- path
id: media.image.default
targetEntityType: media
Expand All @@ -21,12 +21,14 @@ content:
settings: { }
third_party_settings: { }
field_media_image:
type: image_image
type: image_focal_point
weight: 0
region: content
settings:
progress_indicator: throbber
preview_image_style: thumbnail
preview_image_style: large
preview_link: false
offsets: '50,50'
third_party_settings: { }
langcode:
type: language_select
Expand Down
2 changes: 2 additions & 0 deletions apps/cms/config/sync/core.extension.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module:
config_translation: 0
consumers: 0
content_moderation: 0
crop: 0
custom: 0
datetime: 0
datetime_range: 0
Expand All @@ -31,6 +32,7 @@ module:
field_ui: 0
file: 0
filter: 0
focal_point: 0
graphql: 0
graphql_directives: 0
gutenberg: 0
Expand Down
3 changes: 3 additions & 0 deletions apps/cms/config/sync/crop.settings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
_core:
default_config_hash: 7eGOTSG7bRv_AAqu-Ls8CSnob7zPF1ez-lD2OLZgBHs
flush_derivative_images: true
14 changes: 14 additions & 0 deletions apps/cms/config/sync/crop.type.focal_point.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
uuid: 928fcf6c-e6b0-43d2-bef3-50ae2d1cced0
langcode: en
status: true
dependencies: { }
_core:
default_config_hash: flCi9IdafdLXlJqvoHguutUOiC05-aynK4niYN4YZ3o
label: 'Focal point'
id: focal_point
description: 'Crop type used by Focal point module.'
aspect_ratio: ''
soft_limit_width: null
soft_limit_height: null
hard_limit_width: null
hard_limit_height: null
4 changes: 4 additions & 0 deletions apps/cms/config/sync/focal_point.settings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
_core:
default_config_hash: 8JOAPEbjHMB4rDFCsu3EXEx6L2UDQ5SSDyN0d7S0Ic0
crop_type: focal_point
default_value: '50,50'
2 changes: 2 additions & 0 deletions apps/cms/config/sync/language/de/crop.type.focal_point.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
label: Fokuspunkt
description: 'Der vom Focal-Point-Modul verwendete Zuschnittstyp'
39 changes: 39 additions & 0 deletions packages/drupal/custom/src/FocalPoint.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace Drupal\custom;

use Drupal\crop\Entity\Crop;
use Drupal\file\Entity\File;
use Drupal\graphql_directives\DirectiveArguments;

/**
* Helper service for focalpoint information.
*/
class FocalPoint {

/**
* Retrieve the focal point of an image entity.
*
* @param \Drupal\graphql_directives\DirectiveArguments $args
* The directive arguments.
*
* @return array
* The focal point coordinates.
*/
public static function getFocalPoint(DirectiveArguments $args): array {
if ($args->value instanceof File) {
$filePath = $args->value->getFileUri();

$crop = Crop::findCrop($filePath, 'focal_point');
$x = $crop?->x->value;
$y = $crop?->y->value;
if ($x && $y) {
return [
$x,
$y,
];
}
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
_meta:
version: '1.0'
entity_type: crop
uuid: 101ccff9-3733-480e-aca1-392253376a48
bundle: focal_point
default_langcode: en
default:
entity_id:
-
value: 5
entity_type:
-
value: file
uri:
-
value: 'public://2023-04/decoupled-architecture.png'
x:
-
value: 1000
'y':
-
value: 549
revision_timestamp:
-
value: 1725914614
revision_uid:
-
target_id: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
_meta:
version: '1.0'
entity_type: crop
uuid: 10743cfc-604c-4a07-baf3-e267d9c89ff6
bundle: focal_point
default_langcode: en
default:
entity_id:
-
value: 3
entity_type:
-
value: file
uri:
-
value: 'public://media-icons/generic/generic.png'
x:
-
value: 90
'y':
-
value: 90
revision_timestamp:
-
value: 1725914614
revision_uid:
-
target_id: 1
Loading

0 comments on commit 3342876

Please sign in to comment.