Community & Support
Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Editor > disable image resize
RadControls for ASP.NET are no longer supported (see this page for reference). In case you have inquiries about the Telerik ASP.NET AJAX controls, post them in the pertinent ASP.NET AJAX forums.

Not answered disable image resize

Feed from this thread
  • Mikhail B avatar

    Posted on May 19, 2006 (permalink)

    Hello,
    i want to desable resizing images within the editor. I am aware of the method using onresizestart="return false;" However, we do not want to include this with every image tag. My question is there a some sort of global setting for the entire editor to disable image resizing?

    Thank You.

  • Rumen Rumen admin's avatar

    Posted on May 22, 2006 (permalink)


    Hello Mikhail,

    It is not possible to disable the image resize functionality, as it is built into the Internet Explorer's rich-text engine.

    The only workaround would be to set the unselectable="on" or onresizestart="return false;" attribute/event for the images that you do not want the users to be able to resize, e.g.

    <IMG unselectable="on" src="http://www.telerik.com/images/editor/news/teched2004.gif" >

    Best regards,
    Rumen
    the telerik team

  • Vijay avatar

    Posted on Jul 8, 2006 (permalink)

    Hello Rumen,

    Adding unselectable="on" or onresizestart="return false;" in the image tag will disable image resizing in IE. But it does not work in Firefox. Is there any workaround?

    Thanks
    Vijay

  • Rumen Rumen admin's avatar

    Posted on Jul 10, 2006 (permalink)

    Hi Vijay,

    Firefox
    does not implement the unselectable attribute and that is why it does not work in this browser. Unfortunately, we are not aware of a possible solution for Firefox and we will gladly give you 3000 telerik points if you are able to implement and provide a solution on how to disable an element resizing in Firefox.

    We will also post it in our code library on our site.

    Kind regards,
    Rumen,
    the telerik team

  • Mike Bridge Intermediate avatar

    Posted on Sep 12, 2007 (permalink)

    Hi-

    Just wanted to know if there was any update on this.  We have a problem with people "resizing" their images---the resulting HTML gets sent out in an email, but Outlook 2007 is too stupid to honour the dimension attributes in the IMG tag.

    It seems like the easiest way to fix this would be to just disable the resizing.

    Thanks!

    -Mike

  • Rumen Rumen admin's avatar

    Posted on Sep 13, 2007 (permalink)

    Hi Mike,

    You can easily manipulate the images in the content area by using the RadEditor client-side api. Here is an example demonstrating how to strip the width and height attributes and set width and height styles:

    <script type="text/javascript">
        function OnClientSubmit(editor)
        {
            var images = editor.Document.getElementsByTagName("IMG");     
            for (i=0; i<images.length; i++)
            {
               var image = images[i];

               image.style.width = "300px";  
               image.style.height = "300px"; 
                          image.removeAttribute["width"];
               image.removeAttribute["height"];
              
               //or just remove the width and height attributes
                  
            }
        }     
        </script>
        <radE:RadEditor height= 150 id="RadEditor1" OnClientSubmit="OnClientSubmit" SaveInFile="true" ImagesPaths="~/Images" Runat="server">
        <IMG alt="" src="/editor712/Images/Copy.jpg">
        </radE:RadEditor>

    You can enhance the example to fit your scenario.

    You can also use the following code to remove the width and height attributes after the image resizing:

        <script type="text/javascript">
        function OnClientLoad(editor)
        {
          editor.AttachEventHandler("oncontrolselect", function()      
            {      
                //Check if image      
                window.setTimeout(function()      
                {      
                    var selElem = editor.GetSelection().GetParentElement();      
                          
                    if (selElem.tagName == "IMG")       
                    {      
                        selElem.onresizeend = function(e)      
                        {      
                            selElem.style.width = selElem.width;   
                            selElem.style.height = selElem.height;  
                            selElem.removeAttribute("width");
                            selElem.removeAttribute("height");
                           
                            selElem.onresizeend = null;//remove handler      
                        };      
                    }      
                }, 100);      
            });       
        }
        </script>
        <radE:RadEditor height= 150 id="RadEditor1" OnClientLoad="OnClientLoad" ImagesPaths="~/Images" Runat="server">
            <img alt="" src="Images/Desire.jpg">
        </radE:RadEditor>


    Greetings,
    Rumen
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Editor > disable image resize