1

编辑器在调整大小时将样式属性添加到img标签

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

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

经过一些研究后,我发现只有在具有宽度高度属性的图像标签中指定了尺寸时,Outlook才会以所需尺寸显示图像。

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

如何解决这两个问题

4

1 回答 1

1

I resolved the issue using the syncBeforeCallback method to make sure the image also had the width attribute for 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;
        },

I didn't find any case where the height was defined.

于 2014-04-25T15:44:47.793 回答