Fixed image parsing in Firefox
authorAlexander Ebert <ebert@woltlab.com>
Wed, 13 May 2015 16:38:48 +0000 (18:38 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 13 May 2015 16:38:48 +0000 (18:38 +0200)
wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js

index 3486a997c90aef736c0fd539ca916b6e8c44152a..4cbfcc711013f3682107f9eaf39e663beda769e2 100644 (file)
@@ -670,7 +670,13 @@ RedactorPlugins.wbbcode = function() {
                        });
                        
                        // [img]
-                       html = html.replace(/<img [^>]*?src=(["'])([^"']+?)\1[^>]*?style="([^"]+)"[^>]*?>/gi, function(match, quotationMarks, source, style) {
+                       html = html.replace(/<img([^>]*)?src=(["'])([^"']+?)\2([^>]*)?>/gi, function(match, attributesBefore, quotationMarks, source, attributesAfter) {
+                               var attrs = attributesBefore + " " + attributesAfter;
+                               var style = '';
+                               if (attrs.match(/style="([^"]+)"/)) {
+                                       style = RegExp.$1;
+                               }
+                               
                                var $float = 'none';
                                var $width = 0;
                                
@@ -695,8 +701,6 @@ RedactorPlugins.wbbcode = function() {
                                return "[img]" + source + "[/img]";
                        });
                        
-                       html = html.replace(/<img [^>]*?src=(["'])([^"']+?)\1[^>]*?>/gi, '[img]$2[/img]');
-                       
                        // [*]
                        html = html.replace(/<li>/gi, '[*]');
                        html = html.replace(/<\/li>/gi, '\n');