一聚教程网:一个值得你收藏的教程网站

热门教程

.fck编辑器插入图片去掉默认的width和height属性的有效方法

时间:2022-06-25 16:39:14 编辑:袖梨 来源:一聚教程网

打开文件 fckeditor/editor/dialog/fck_image/fck_images.js
注释以下代码即可

 代码如下 复制代码

    if ( oImage.style.width )
    {
        var aMatchW  = oImage.style.width.match( regexSize ) ;
        if ( aMatchW )
        {
            iWidth = aMatchW[1] ;
            oImage.style.width = '' ;
            SetAttribute( oImage, 'width' , iWidth ) ;
        }
    }

    if ( oImage.style.height )
    {
        var aMatchH  = oImage.style.height.match( regexSize ) ;
        if ( aMatchH )
        {
            iHeight = aMatchH[1] ;
            oImage.style.height = '' ;
            SetAttribute( oImage, 'height', iHeight ) ;
        }
    }

    GetE('txtWidth').value    = iWidth ? iWidth : GetAttribute( oImage, "width", '' ) ;
    GetE('txtHeight').value    = iHeight ? iHeight : GetAttribute( oImage, "height", '' ) ;
----------
    SetAttribute( e, "width" , GetE('txtWidth').value ) ;
    SetAttribute( e, "height", GetE('txtHeight').value ) ;
----------
    if ( bLockRatio )
    {
        if ( GetE('txtWidth').value.length > 0 )
            OnSizeChanged( 'Width', GetE('txtWidth').value ) ;
        else
            OnSizeChanged( 'Height', GetE('txtHeight').value ) ;
    }
----------
    var e = dimension == 'Width' ? GetE('txtHeight') : GetE('txtWidth') ;
----------
    if ( dimension == 'Width' )
        value = value == 0 ? 0 : Math.round( oImageOriginal.height * ( value  / oImageOriginal.width ) ) ;
    else
        value = value == 0 ? 0 : Math.round( oImageOriginal.width  * ( value / oImageOriginal.height ) ) ;
----------
    GetE('txtWidth').value  = oImageOriginal.width ;
    GetE('txtHeight').value = oImageOriginal.height ;
----------
        GetE('txtWidth').value = width ? width : '' ;
        GetE('txtHeight').value = height ? height : '' ;

热门栏目