2

We are working on Sitecore 10.4 and using edit frames to make components editable with complex fields. However, I want to avoid making each field editable separately.

For simple fields like the title, I'm using i_item.Title.raw. But for the image field, I’m unable to apply .raw.

Could someone help me make the image field non-editable in the Experience Editor? Below is my current code:

{{ sc_query i_item "Thumbnail Image" }}

Any help would be greatly appreciated!

1 Answer 1

1

In order to achieve this, you can read the media url of the image field using sc_medialink property and this can be then used to create the img tag.

{{ mediaItem = sc_follow i_item 'Thumbnail Image' }} 
{{ if mediaItem}}
    {{ mediaItemUrl = mediaItem | sc_medialink }}
    {{ mediaItemAlt = mediaItem.alt.raw  }}
    <img src="{{mediaItemUrl}}" alt="{{mediaItemAlt}}"/>
{{ end }}

Hope this helps!!! Let me know in case you have any queries.

2
  • Thanks for the response, @ckhanna! However, my field name is "Thumbnail Image" which contains a whitespace. How can I handle this?
    – Olive
    Commented Sep 28 at 12:41
  • @Olive I have updated the answer above for the case when the field name contains white space in it. Please let me know in case you have any doubts.
    – ckhanna
    Commented Sep 28 at 15:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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