plone / blocks-conversion-tool

A tool to convert HTML (as used in Plone Classic) to Blocks (as used on Volto)
7 stars 5 forks source link

Images with links are not converted properly #29

Closed shogunbr closed 1 year ago

shogunbr commented 1 year ago

If you have HTML with an image inside an <a href> tag, like this:

<p>
    <a href="https://plone.org.br/" data-linktype="external" data-val="https://plone.org.br/">
        <img class="image-richtext" alt="" src="https://plone.org.br/static/media/Logo.4aa11740.svg" data-linktype="externalImage" data-scale="teaser" data-val="https://plone.org.br/static/media/Logo.4aa11740.svg" />
    </a>
</p>

It is converted into:

 "c19a5061-4fd6-4ce3-9436-b70a04cc0c93": {
  "@type": "image",
  "url": "https://plone.org.br/static/media/Logo.4aa11740.svg",
  "alt": "",
  "title": "",
  "href": {
   "url": "https://plone.org.br/"
  },
  "align": "center",
  "size": "l"
 }

Volto shows the image, but if you click on it, there is no clickable link..

If you create an image with a link directly on Volto, it is created in a different format, using @id instead of url, which makes the image clickable:

 "1dd912e6-b46b-4fa1-ac38-13c5a542d180": {
  "@type": "image",
  "url": "https://plone.org.br/static/media/Logo.4aa11740.svg",
  "href": [
   {
    "@id": "https://plone.org.br/",
    "title": "plone.org.br/"
   }
  ]
 }