4

Using SXA 1.2 rev. 161216, I am not able to click on an image's external link even when I specified one in it's URL field.

How to enable it ?

1

You just have to edit the Image.cshtml view and change the following condition,

@if (Model.LinkItem != null && Model.LinkItem.TargetItem != null)

for

@if (Model.LinkItem != null && (Model.LinkItem.TargetItem != null || (!Model.LinkItem.IsInternal && !string.IsNullOrEmpty(Model.LinkItem.TargetUrl))))

as a matter of fact, in case there is an external link, the LinkItem.TargetItem is null and we need to get into this piece of code and in the case there is no specified link, we need to avoid getting in the code because it would render a link to this page (thank you guschti !)

  • 2
    If you just remove the second condition, also images with no explicitly set link will render with a link tag referencing the current page. I'd suggest to extend the condition as follows: @if (Model.LinkItem != null && (Model.LinkItem.TargetItem != null || (!Model.LinkItem.IsInternal && !string.IsNullOrEmpty(Model.LinkItem.TargetUrl)))) – guschti Jul 6 '17 at 7:56

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.