diff --git a/src/app/app.scss b/src/app/app.scss index b94b80ce2..9050f69cc 100644 --- a/src/app/app.scss +++ b/src/app/app.scss @@ -32,7 +32,6 @@ .img-responsive { display: block; max-width: 100%; - height: auto; } .opacity-hide { opacity: 0; } @@ -270,6 +269,7 @@ core-format-text[ng-reflect-single-line="true"] { } img.core-media-adapt-width { + width: 100%; height: auto; } @@ -280,6 +280,7 @@ audio.core-media-adapt-width { .core-adapted-img-container { position: relative; display: inline-block; + width: 100%; } .core-image-viewer-icon { diff --git a/src/directives/format-text.ts b/src/directives/format-text.ts index 6bcfb78fd..ab21ca81a 100644 --- a/src/directives/format-text.ts +++ b/src/directives/format-text.ts @@ -117,6 +117,11 @@ export class CoreFormatTextDirective implements OnChanges { // Element to wrap the image. container = document.createElement('span'); + const forcedWidth = parseInt(img.attributes.getNamedItem('width').value); + if (!isNaN(forcedWidth) && img.attributes.getNamedItem('width').value.indexOf('%') < 0) { + img.style.width = forcedWidth + 'px'; + } + container.classList.add('core-adapted-img-container'); container.style.cssFloat = img.style.cssFloat; // Copy the float to correctly position the search icon. if (img.classList.contains('atto_image_button_right')) {