Skip to content

Commit d03a9c7

Browse files
author
Daniel Morse
committed
feat: skip ratio if 'cover' attribute is true
1 parent 2049a70 commit d03a9c7

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

packages/components/bolt-image/src/image.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ class BoltImage extends withLitHtml() {
125125
}
126126

127127
const _isJpg = path.extname(src) === '.jpg';
128-
const _canUseRatio = ratioW > 0 && ratioH > 0 && useRatio;
128+
const _canUseRatio = ratioW > 0 && ratioH > 0 && useRatio && !cover;
129129
// Only JPGs allowed, PNGs can have transparency and may not look right layered over placeholder
130130
const _canUsePlaceholder = (_canUseRatio || cover) && _isJpg;
131131

@@ -177,7 +177,9 @@ class BoltImage extends withLitHtml() {
177177
return html`
178178
<noscript>
179179
<img
180-
class="${cx('c-bolt-image__image')}"
180+
class="${cx('c-bolt-image__image', {
181+
'c-bolt-image--cover': cover,
182+
})}"
181183
src="${src}"
182184
alt="${ifDefined(alt ? alt : undefined)}"
183185
srcset="${ifDefined(!lazyload ? srcset || src : undefined)}"

packages/components/bolt-image/src/image.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
{% set is_jpg = src|split('.')|last == "jpg" %}
2929
{% set useAspectRatio = useAspectRatio ?? true %}
30-
{% set can_use_ratio = width > 0 and height > 0 and useAspectRatio is sameas(true) %}
30+
{% set can_use_ratio = width > 0 and height > 0 and useAspectRatio is sameas(true) and object is sameas(false) %}
3131
{# Only JPGs allowed, PNGs can have transparency and may not look right layered over placeholder #}
3232
{% set can_use_placeholder = can_use_ratio or cover %}
3333

0 commit comments

Comments
 (0)