0
0
Fork 0

Change media elements to use aspect-ratio rather than compute height themselves (#24686)

This commit is contained in:
Claire 2023-05-02 13:58:48 +02:00 committed by GitHub
parent 1eb51bd749
commit 598e63dad2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 40 additions and 136 deletions

View file

@ -313,7 +313,7 @@ class MediaGallery extends React.PureComponent {
}
render () {
const { media, lang, intl, sensitive, height, defaultWidth, standalone, autoplay } = this.props;
const { media, lang, intl, sensitive, defaultWidth, standalone, autoplay } = this.props;
const { visible } = this.state;
const width = this.state.width || defaultWidth;
@ -322,13 +322,9 @@ class MediaGallery extends React.PureComponent {
const style = {};
if (this.isFullSizeEligible() && (standalone || !cropImages)) {
if (width) {
style.height = width / this.props.media.getIn([0, 'meta', 'small', 'aspect']);
}
} else if (width) {
style.height = width / (16/9);
style.aspectRatio = `${this.props.media.getIn([0, 'meta', 'small', 'aspect'])}`;
} else {
style.height = height;
style.aspectRatio = '16 / 9';
}
const size = media.take(4).size;