fix: aspect ratio improvements (#2171)

- Use CSS aspect-ratio (retain fallback for legacy browsers)
- Round aspect ratios (fixes YouTube black border issue)
This commit is contained in:
Sam Potts
2021-04-18 16:58:44 +10:00
committed by GitHub
parent ddb5ad071e
commit 438e425838
6 changed files with 67 additions and 16 deletions

View File

@ -11,7 +11,7 @@ import loadImage from '../utils/load-image';
import loadScript from '../utils/load-script';
import { extend } from '../utils/objects';
import { format, generateId } from '../utils/strings';
import { setAspectRatio } from '../utils/style';
import { roundAspectRatio, setAspectRatio } from '../utils/style';
// Parse YouTube ID from URL
function parseId(url) {
@ -90,7 +90,7 @@ const youtube = {
ui.setTitle.call(this);
// Set aspect ratio
this.embed.ratio = [width, height];
this.embed.ratio = roundAspectRatio(width, height);
}
setAspectRatio.call(this);