MOBILE-2566 ux: Check also image size in percentage
parent
51a9f28764
commit
8957ffabae
|
@ -299,7 +299,6 @@ core-format-text[ng-reflect-single-line="true"] {
|
||||||
}
|
}
|
||||||
|
|
||||||
img.core-media-adapt-width {
|
img.core-media-adapt-width {
|
||||||
width: 100%;
|
|
||||||
height: auto;
|
height: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -117,11 +117,16 @@ export class CoreFormatTextDirective implements OnChanges {
|
||||||
protected adaptImage(elWidth: number, img: HTMLElement): void {
|
protected adaptImage(elWidth: number, img: HTMLElement): void {
|
||||||
const imgWidth = this.getElementWidth(img),
|
const imgWidth = this.getElementWidth(img),
|
||||||
// Element to wrap the image.
|
// 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);
|
const forcedWidth = parseInt(originalWidth && originalWidth.value);
|
||||||
if (!isNaN(forcedWidth) && img.attributes.getNamedItem('width').value.indexOf('%') < 0) {
|
if (!isNaN(forcedWidth)) {
|
||||||
img.style.width = forcedWidth + 'px';
|
if (originalWidth.value.indexOf('%') < 0) {
|
||||||
|
img.style.width = forcedWidth + 'px';
|
||||||
|
} else {
|
||||||
|
img.style.width = forcedWidth + '%';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
container.classList.add('core-adapted-img-container');
|
container.classList.add('core-adapted-img-container');
|
||||||
|
|
Loading…
Reference in New Issue