Uploaded image for project: 'Magnolia Demo Projects'
  1. Magnolia Demo Projects
  2. MGNLDEMO-389

Demo: TextImage component does not render/error if Asset-Link is broken

    XMLWordPrintable

Details

    • Task
    • Resolution: Unresolved
    • Neutral
    • None
    • 1.6.3
    • None
    • None

    Description

      Reproduce

      1. Upload a new Asset.
      2. Use this Asset in a textImage component
      3. Publish the page you linked in the component to the asset -> Render the page on the public -> reproduction on public
        OR
        Delete the Asset -> Render the page on the public -> reproduction on Author.

      Problem

      The textImage component renders a null-pointer error if the is an non-rsolvable asset link.
      There is a missing null handling -> "assetLink could not be resolved to an asset via the damfn.

      Solution

      Use this code:
      With a proper null check on the 'rendition' object.

      [#if content.image?has_content]
          [#assign rendition = damfn.getRendition(content.image, "original")!]
          [#if rendition?has_content]
              [#assign hasImage = true]
              [#assign divClass = "${divClass} text-image-section"]
              [#assign imageClass = "content-image-${imagePosition}"]
              [#include "/travel-demo/templates/macros/imageResponsive.ftl"]
              [#assign imageHtml][@imageResponsive rendition content imageClass false def.parameters /][/#assign]
          [/#if]
      [/#if]
      

      I have attached the whole script file to replace.
      textImage.ftl

      Checklists

        Acceptance criteria

        Attachments

          Activity

            People

              Unassigned Unassigned
              cringele Christian Ringele
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Checklists

                  Task DoR