1

I have cloned the SXA Image Component by creating a new view file, new template and new rendering parameters template.

enter image description here

There is a URL field in the item and I have inserted an external link in here. I have also created a rendering variant with a single image field (Is Link set to true). But the output for the link (href) is always #.

enter image description here

enter image description here

1 Answer 1

1

The SXA image component does not work this wway.. it looks for the TargetUrl field from the Image datasource template (it uses the actual guid for this - {54CAB1BA-53D3-4CE4-AB7E-F8C17596AA47}).

The variant is rendered with this value (or # if not found) as a "href override". That is where the url comes from..

Without this, the "Is link" would link to the context item (at that moment), which would mean your link goes to the image item itself what would be pointless.

So if you want to customize the image component, use the original template as a base template for your own. This way you will have the TargetUrl field in your template.

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.