【问题标题】:Redactor image resize adding inline style attributes, how to force redactor to use "width" and "height" attributes编辑器图像调整大小添加内联样式属性,如何强制编辑器使用“宽度”和“高度”属性
【发布时间】:2013-07-17 20:22:55
【问题描述】:

编辑器在调整大小时将 style 属性添加到 img 标记

<img src="image_url" style="width: 189.00884955752213px; height: 118px;" >

在 Outlook 桌面应用程序中查看时,此内联 css 不会影响图像大小。

经过一番研究,我发现只有在具有 widthheight 属性的图像标签中指定尺寸时,Outlook 才会以所需尺寸显示图像。 p>

Redactor 生成的 style 属性中的宽度值也不是整数 189.00884955752213px。

如何解决这两个问题

【问题讨论】:

    标签: jquery width wysiwyg inline-styles redactor


    【解决方案1】:

    我使用 syncBeforeCallback 方法解决了这个问题,以确保图像也具有 Outlook 的宽度属性

            syncBeforeCallback: function (html)
            {
                // set image width as attribute (for outlook)
                var $html = $('<div/>').html(html);
                $html.find('img').each(function copyImageCssWidthToAttribute() {
                    var width = parseInt($(this).css('width'));
                    if (width > 0) {
                        $(this).attr('width', width);
                    }
                });
                html = $html.html();
                return html;
            },
    

    我没有找到任何定义高度的情况。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-11-10
      • 1970-01-01
      • 2023-02-07
      • 2020-05-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多