[MTE-103] Stacktrace on missing image for MTK/Image component Created: 03/Feb/17  Updated: 08/Jun/20  Resolved: 08/Jun/20

Status: Closed
Project: Magnolia Templating Essentials
Component/s: None
Affects Version/s: 1.1.1
Fix Version/s: None

Type: Bug Priority: Neutral
Reporter: Martijn Kooijman Assignee: Unassigned
Resolution: Cannot Reproduce Votes: 2
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:

 Description   

In my project, I am using mtk:components/image component.

I have selected an image and it works fine.

Now the image is deleted and the component throws:
FreeMarker template error (HTML_DEBUG mode; use RETHROW in production!)

The following has evaluated to null or missing:
==> damfn.getRendition(content.image, "original") [in template "mtk/templates/components/image.ftl" at line 14, column 26]

It looks like the code at mtk/templates/components/image.ftl:line 14 is not handling null-values very well, because getRendition can return null when the image is not there:
assign rendition = damfn.getRendition(content.image, "original")



 Comments   
Comment by Richard Gange [ 08/Jun/20 ]

Trying to recreate this I am unable to delete the image without deleting the entire component. Once an image is selected you have to reselect another image.

Second, before the rendition is applied a check is made for content in image.

[#if content.image?has_content]
    [#assign rendition = damfn.getRendition(content.image, "original")]
    [#include "/mtk/templates/macros/image.ftl"]
[/#if]

So it is indeed handling null values.

Comment by Richard Gange [ 08/Jun/20 ]

Tested in 6.2.1.

Generated at Mon Feb 12 13:40:25 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.