Skip to content

Commit

Permalink
Merge pull request #1237 from openeuropa/EWPP-3048
Browse files Browse the repository at this point in the history
EWPP-3048: Do not apply custom ratio class on iframes.
  • Loading branch information
nagyad authored Feb 1, 2023
2 parents e122f78 + e0981fc commit 1c59189
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 12 deletions.
3 changes: 1 addition & 2 deletions oe_theme.theme
Original file line number Diff line number Diff line change
Expand Up @@ -1668,8 +1668,7 @@ function oe_theme_preprocess_field__media__oe_media_iframe__video_iframe__oe_the
* Prepared ratio to be used in templates.
*/
function _oe_theme_get_oe_media_iframe_ratio(MediaInterface $media): string {
$ratio = $media->get('oe_media_iframe_ratio')->value ?? 'custom';
return str_replace('_', '-', $ratio);
return $media->get('oe_media_iframe_ratio')->isEmpty() ? '' : str_replace('_', '-', $media->get('oe_media_iframe_ratio')->value);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@
"@ecl/vanilla-utility-background": "3.6.0",
"@ecl/vanilla-utility-border": "3.6.0",
"chokidar-cli": "1.2.0",
"grunt": "^1.4.0",
"grunt-contrib-copy": "^1.0.0",
"grunt": "1.4.0",
"grunt-contrib-copy": "1.0.0",
"moment": "2.29.1",
"node-sass": "4.13.1",
"npm-run-all": "4.0.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@
{% include '@ecl-twig/media-container' with {
'embedded_media': item.content,
'ratio': ratio,
'extra_classes': (ratio == 'custom') ? 'ecl-media-container--custom-ratio' : '',
} %}
{% endfor %}
4 changes: 0 additions & 4 deletions templates/paragraphs/paragraph--oe-iframe-media.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
{% set extra_classes = ['ecl-media-container--fullwidth'] %}
{% endif %}

{% if ratio == 'custom' %}
{% set extra_classes = extra_classes|merge(['ecl-media-container--custom-ratio']) %}
{% endif %}

{% if not paragraph.field_oe_title.isEmpty() %}
<h2 class="ecl-u-type-heading-2">{{ content.field_oe_title }}</h2>
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion tests/src/Kernel/MediaRenderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ public function testIframeMedia(): void {
$build = $this->mediaViewBuilder->view($media, 'oe_theme_main_content');
$html = $this->renderRoot($build);
$crawler = new Crawler($html);
$iframe = $crawler->filter('.ecl-media-container .ecl-media-container__media--ratio-custom iframe');
$iframe = $crawler->filter('.ecl-media-container iframe');
$this->assertEquals('http://example.com/iframe_media', $iframe->attr('src'));

// Assert iframe media with aspect ratio 3:2.
Expand Down
4 changes: 2 additions & 2 deletions tests/src/Kernel/Paragraphs/MediaParagraphsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -891,15 +891,15 @@ public function testIframe(): void {
$this->container->get('entity_type.manager')->getAccessControlHandler('media')->resetCache();
$html = $this->renderParagraph($paragraph);
$crawler = new Crawler($html);
$iframe = $crawler->filter('figure.ecl-media-container.ecl-media-container--custom-ratio div.ecl-media-container__media.ecl-media-container__media--ratio-custom iframe');
$iframe = $crawler->filter('figure.ecl-media-container div.ecl-media-container__media iframe');
$this->assertStringContainsString('http://example.com/iframe', $iframe->attr('src'));
$this->assertStringNotContainsString('ecl-u-type-heading-2', $html);

// Assert "Full width" field.
$paragraph->set('field_oe_iframe_media_full_width', TRUE)->save();
$html = $this->renderParagraph($paragraph);
$crawler = new Crawler($html);
$iframe = $crawler->filter('figure.ecl-media-container.ecl-media-container--fullwidth.ecl-media-container--custom-ratio div.ecl-media-container__media.ecl-media-container__media--ratio-custom iframe');
$iframe = $crawler->filter('figure.ecl-media-container.ecl-media-container--fullwidth div.ecl-media-container__media iframe');
$this->assertStringContainsString('http://example.com/iframe', $iframe->attr('src'));

// Assert ratio.
Expand Down

0 comments on commit 1c59189

Please sign in to comment.