From 06e3f815216ce1631b9e3fb974e54d7f86dcb1fc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= <crazyserver@gmail.com>
Date: Mon, 6 Aug 2018 15:58:25 +0200
Subject: [PATCH] MOBILE-2474 ux: Scale SVG propperly on iOS

---
 src/app/app.scss              | 3 ++-
 src/directives/format-text.ts | 5 +++++
 2 files changed, 7 insertions(+), 1 deletion(-)

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')) {