Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Strange behaviour inserting images in CMS

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Page: 1
Go to End
Author Topic: 1152 Views
  • nomen
    Avatar
    Community Member
    52 Posts

    Strange behaviour inserting images in CMS Link to this post

    Hi all:

    I´m using SS 2.2.1
    If I add images to a page in CMS with Firefox there is not problem.
    But if i add images to a page in CMS with IE, there is an XML error in the resulting page(we can see it, opening the page with Firefox. See ErrorXML_1.jpg).

    As you can see in ErrorXML_2.jpg, the error is produced because the editor inserts strange JavaScript code.

    Someone has the same problem?

    thanks in advance.

  • nomen
    Avatar
    Community Member
    52 Posts

    Re: Strange behaviour inserting images in CMS Link to this post

    Hi all:

    I have discovered that the code that creates the problem is in jsparty/tiny_mce_improvements.js, concretely in onmouseup function.
    The content in this function is inserted in the HTML. I can´t find when is inserted.
    If I delete the function, it works better (no XML error in Firefox), but i have discovered that TinyMCE adds this chunk code to the image:

    resizeTo="function(width, height) {       var newWidth = parseInt(height);       var newHeight = parseInt(height) - this.heightDiff;       if(isNaN(newWidth)) newWidth = this.width;       if(isNaN(newHeight)) newHeight = this.height;              // Constrain to width of the window       if((this.offsetLeft + this.offsetWidth + 20) > this.ownerDoc().offsetWidth)          newWidth += (this.ownerDoc().offsetWidth - this.offsetLeft - this.offsetWidth - 20);           if(this.aspectRatio) {          // Figure out which dimension we have altered more          var heightChange = this.originalHeight / this.height;          if(heightChange < 1) heightChange = 1/heightChange;                    var widthChange = this.originalWidth / this.width;          if(widthChange < 1) widthChange = 1/widthChange;                    // Scale by the more constant dimension (so if you edit the height, change width to suit)          if(widthChange > heightChange)             newHeight = newWidth * this.aspectRatio;          else             newWidth = newHeight / this.aspectRatio;       }       this.style.width = newWidth + 'px';       this.style.height = newHeight + 'px';       this.width = newWidth;       this.height = newHeight;                 // Auto-size special image holders       if(this.parentNode.parentNode.className.match(/(^|\b)specialImage($|\b)/)) {          this.parentNode.parentNode.style.width = newWidth + 'px';       }    }" ownerDoc="function() {       var f =this.parentNode;       while(f && f.tagName.toLowerCase() != 'body') f = f.parentNode;       return f;    }" prepareForResize="function() {       if(this.aspectRatio == null) {          this.aspectRatio = this.height / this.width;       }           this.originalWidth = this.width;       this.originalHeight = this.height;    }" _onclick="function() {       var form = $('Form_EditorToolbarImageForm');       if(form) {          form.elements.AltText.value = this.alt;          form.elements.CSSClass.value = this.className;       }    }" initialize="function() {       TinyMCE.prototype.addEvent(this, 'click', this._onclick);    }"

    I also have discovered that the image is moved to assets/imagenes/_resampled/ResizedImage545161-img.jpg directory and i don´t understand why because i have used the image without resizing.
    Any idea about avoiding to resizing images in SS?

  • Ingo
    Avatar
    Forum Moderator
    801 Posts

    Re: Strange behaviour inserting images in CMS Link to this post

    hm, i can't find this javascript code anywhere - the tiny_mce_improvements has similiar javascript, but not in the resizeTo="function()..." notation. where did you find this code?
    there's most likely a curly brace too many, do you get a javascript error as well?

  • nomen
    Avatar
    Community Member
    52 Posts

    Re: Strange behaviour inserting images in CMS Link to this post

    Hi Ingo:

    Thank you very much for analizing this problem.
    The code inserted is in tiny_mce_improvements.js file.
    The resizeTo code is in the resizeTo: function the ownerDoc is in ownerDoc: function and so on.
    I don´t know how to debug to know where TiniMCE decides to insert this or not. By the way i have to say that saving the same content this chunk of code is not always inserted

    1152 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.