Merge pull request #1487 from crazyserver/MOBILE-2566

MOBILE-2566 ux: Check also image size in percentage
main
Juan Leyva 2018-08-24 13:10:56 +01:00 committed by GitHub
commit 9f7e5087c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 5 deletions

View File

@ -299,7 +299,6 @@ core-format-text[ng-reflect-single-line="true"] {
}
img.core-media-adapt-width {
width: 100%;
height: auto;
}

View File

@ -117,11 +117,16 @@ export class CoreFormatTextDirective implements OnChanges {
protected adaptImage(elWidth: number, img: HTMLElement): void {
const imgWidth = this.getElementWidth(img),
// Element to wrap the image.
container = document.createElement('span');
container = document.createElement('span'),
originalWidth = img.attributes.getNamedItem('width');
const forcedWidth = parseInt(img.attributes.getNamedItem('width').value);
if (!isNaN(forcedWidth) && img.attributes.getNamedItem('width').value.indexOf('%') < 0) {
img.style.width = forcedWidth + 'px';
const forcedWidth = parseInt(originalWidth && originalWidth.value);
if (!isNaN(forcedWidth)) {
if (originalWidth.value.indexOf('%') < 0) {
img.style.width = forcedWidth + 'px';
} else {
img.style.width = forcedWidth + '%';
}
}
container.classList.add('core-adapted-img-container');