mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
use intrinsic aspect-ratio supported by chrome and firefox (although not safari)
This commit is contained in:
parent
aa0692da3e
commit
0e5ad9805a
@ -27,23 +27,10 @@
|
|||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
.message-container a {
|
|
||||||
display: block;
|
|
||||||
position: relative;
|
|
||||||
max-width: 100%;
|
|
||||||
/* width and padding-top set inline to maintain aspect ratio,
|
|
||||||
replace with css aspect-ratio once supported */
|
|
||||||
}
|
|
||||||
|
|
||||||
.message-container img {
|
.message-container img {
|
||||||
display: block;
|
display: block;
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
bottom: 0;
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.TextMessageView {
|
.TextMessageView {
|
||||||
|
@ -2,19 +2,17 @@ import {TemplateView} from "../../../general/TemplateView.js";
|
|||||||
|
|
||||||
export class ImageView extends TemplateView {
|
export class ImageView extends TemplateView {
|
||||||
render(t, vm) {
|
render(t, vm) {
|
||||||
// replace with css aspect-ratio once supported
|
|
||||||
const heightRatioPercent = (vm.thumbnailHeight / vm.thumbnailWidth) * 100;
|
|
||||||
const image = t.img({
|
const image = t.img({
|
||||||
src: vm.thumbnailUrl,
|
src: vm.thumbnailUrl,
|
||||||
width: vm.thumbnailWidth,
|
width: vm.thumbnailWidth,
|
||||||
height: vm.thumbnailHeight,
|
height: vm.thumbnailHeight,
|
||||||
loading: "lazy",
|
loading: "lazy",
|
||||||
|
style: `max-width: ${vm.thumbnailWidth}px`,
|
||||||
alt: vm.label,
|
alt: vm.label,
|
||||||
});
|
});
|
||||||
const linkContainer = t.a({
|
const linkContainer = t.a({
|
||||||
href: vm.url,
|
href: vm.url,
|
||||||
target: "_blank",
|
target: "_blank"
|
||||||
style: `padding-top: ${heightRatioPercent}%; width: ${vm.thumbnailWidth}px;`
|
|
||||||
}, image);
|
}, image);
|
||||||
|
|
||||||
return t.li(
|
return t.li(
|
||||||
|
Loading…
Reference in New Issue
Block a user