5

Inside the Rich Text field, we could add a new image. But when we resize the image by default tool, the new size couldn't be saved and it always be turned back to the default setting.

Step 1 is the screenshot when we add the image;

enter image description here

Step 2 is when we resized the image and saved the setting. It is much smaller than the default one;

enter image description here

Step 3 is when we move the mouse focus out of the image and try to save the entire page. Before we save the page the setting be rolled back.

enter image description here

As you can see at Step 3, the size be turned back to what we saw at step 1.

  • Are you sure the size is not saved (as XHTML attributes) in CM? Note tha DXA by default uses responsive image sizing and hence does not respect any fixed image size stored in CM. – Rick Pannekoek Apr 25 '17 at 17:22
2

The problem isn't so much related to the Image Resize in Experience Manager, but is all due to the XSLT filter which is applied to the xontent field of the Paragraph embeddable Schema that is used in the Article Schema for the articleBody field.

To remove some unwanted markup when content was pasted from for example MS Word, we strip all style attributes. Now when you try to change the size of an image in a Rich Text Field, this is written in a style attribute in the image tag.

Since the example DXA site was created in a responsive design, we wanted all images to be full width in the article content, and resized to browser/screen width. Hence we didn't care about the removal of the style attribute in the image tag.

If you want to reenable this functionality, you have to modify the XSLT filter on the content field of the Paragraph Embedddable Schema (100 Master - Building Blocks - Modules - Core - Editor - Schemas - Embedded).

Modify the following part of the XSLT filter:

<!-- remove all style attributes except those for a table and its cells and to allow underline -->
<xsl:template match="*[not(local-name() = &apos;table&apos; or local-name() = &apos;tr&apos; or local-name() = &apos;th&apos; or local-name() = &apos;td&apos; or local-name() = &apos;col&apos;)]/@style"></xsl:template>

into:

<!-- remove all style attributes except those for an image, a table and its cells and to allow underline -->
<xsl:template match="*[not(local-name() = &apos;table&apos; or local-name() = &apos;tr&apos; or local-name() = &apos;th&apos; or local-name() = &apos;td&apos; or local-name() = &apos;col&apos; or local-name() = &apos;img&apos;)]/@style"></xsl:template>

Please note that after this change your Schema is changed, but it might still be cache by the Content Manager in some instances, so it could take a while for the change to take effect (pressing F5 in the Component window might do the trick).

After this you will be able to save the Component, while retaining the style attribute on the image, but the default DXA example site HTML design, will not respect it still I think. You will have to make changes to the HTML design to leave the images in a Rich Text Field as is, and maybe even in the Media Helper in the DXA web application. I'm hoping at least my answer will give you insight into why it was happening, and send you on to a solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.