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

EWPP-3650: Use ECL media container picture parameter instead of image and alt. #1336

Merged
merged 1 commit into from
Dec 15, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@
{% if image is not empty %}
<div class="ecl-col-12 ecl-col-m-3">
{% include '@ecl-twig/media-container' with {
'image': image.src,
'alt': image.alt,
'picture': {
'img': {
'src': image.src,
'alt': image.alt,
},
},
'extra_classes': 'ecl-u-bg-white'
} %}
</div>
Expand Down
12 changes: 8 additions & 4 deletions modules/oe_theme_helper/oe_theme_helper.module
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ function template_preprocess_oe_theme_helper_featured_media(array &$variables) {
return $variables;
}

// If its an AvPortal video or an iframe video, render it.
// If it's an AvPortal video or an iframe video, render it.
$params['embedded_media'] = $media->{$source_field->getName()}->view($display_options);

// When dealing with iframe videos, also respect its given aspect ratio.
Expand All @@ -219,7 +219,7 @@ function template_preprocess_oe_theme_helper_featured_media(array &$variables) {
return $variables;
}

// If it's an image media, render it and assign it to the image variable.
// If it's an image media, render it and assign it to the picture variable.
/** @var \Drupal\image\Plugin\Field\FieldType\ImageItem $thumbnail */
$thumbnail = $media->get('thumbnail')->first();
/** @var \Drupal\Core\Entity\Plugin\DataType\EntityAdapter $file */
Expand All @@ -240,8 +240,12 @@ function template_preprocess_oe_theme_helper_featured_media(array &$variables) {
$image_url = \Drupal::service('file_url_generator')->generateAbsoluteString($file->get('uri')->getString());
}

$params['alt'] = $thumbnail->get('alt')->getString();
$params['image'] = $image_url;
$params['picture'] = [
'img' => [
'src' => $image_url,
'alt' => $thumbnail->get('alt')->getString(),
],
];
$variables['params'] = $params;
$cacheability->applyTo($variables);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
* @ingroup themeable
*/
#}
{% if params.image or params.embedded_media %}
{% if params.picture or params.embedded_media %}
{% include '@ecl-twig/media-container' with params only %}
{% endif %}
12 changes: 0 additions & 12 deletions patches/@ecl/twig-component-media-container+3.11.1.patch

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@
{% if image %}
<div class="ecl-u-mb-l">
{% include '@ecl-twig/media-container' with {
'image': image.src,
'alt': image.alt,
'picture': {
'img': {
'src': image.src,
'alt': image.alt,
},
},
'extra_classes': 'ecl-u-bg-white ecl-u-shadow-none'
} %}
</div>
Expand Down
8 changes: 6 additions & 2 deletions templates/paragraphs/paragraph--oe-av-media.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
#}
{% if image %}
{% set media_container = {
'image': image.src,
'alt': image.alt,
'picture': {
'img': {
'src': image.src,
'alt': image.alt,
},
},
} %}
{% elseif video %}
{% set media_container = {
Expand Down
8 changes: 6 additions & 2 deletions templates/patterns/file_image/pattern-file-image.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
*/
#}
{% include '@ecl-twig/media-container' with {
'image': src,
'alt': alt,
'picture': {
'img': {
'src': src,
'alt': alt,
},
},
'description': caption,
} %}