Uploaded image for project: 'Confluence Data Center'
  1. Confluence Data Center
  2. CONFSERVER-13464

Links containing images with center alignment break when converted from the rich text editor

XMLWordPrintable

      As reported in CONF-7143, links that contain images with center alignment break when converted from the rich text editor.

      Eg

      [!image.png|align=center!|Link Text]
      

      Creates the following xhtml

      <a aliasspecified="true" wikidestination="Link Text" linktype="raw" title="Link Text" mce_href="../../../../../../../../../confluence/display/DEFAULT/Link+Text" href="/confluence/display/DEFAULT/Link+Text">
      <div align="center">
      <img border="0" imagetext="images-1.jpg|align=center" mce_src="../../../../../../../../../confluence/download/attachments/950278/images-1.jpg" src="/confluence/download/attachments/950278/images-1.jpg"/>
      </div>
      </a>
      

      Which creates the following wiki markup on the return trip

      [|Link Text] !images-1.jpg|align=center!
      
      • In the HTML an extra div with align=center is wrapped around the img tag because just setting align=centre on the img tag doesn't work on the major browsers, although align=right does.
      • This div is not valid HTML, since the a tag only allows inline children http://www.w3.org/TR/html401/struct/links.html#h-12.2.
      • As a result, the xhtml parser doesn't return the div within the link tag, and the conversion to wiki markup goes awry.

      Possible fixes or partial fixes:

      • In markup -> all html: Find a better work-around for the non-working centre=align problem. (We've tried but came up with nothing)
      • In wysiwyg -> markup: Put in a really specific piece of logic to convert the broken dom back into the right wiki markup (two hacks don't make a nice piece of code)
      • In markup -> wysiwyg: Don't render the div for wysiwyg, letting the image show not-centred (violating the what you see is what you get bit)
      • In markup -> all html: Try to pass the need to centre the html back up to the paragraph containing the link?

      Workarounds

      • None yet. (except Don't center images in links). Maybe use a macro to display images instead of the standard syntax.

              smansour Sherif Mansour
              don.willis@atlassian.com Don Willis
              Votes:
              1 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved: