Make the SXA image component load image in XPE - just a couple of hacks
Further Update:
I raised a Sitecore Support case and based on the response, I later created the following blog post so, you can skip to this post instead:
https://navansitecorenotes.blogspot.com/2023/08/why-is-image-not-displayed-in.html
If you want some context, you can continue reading this post!
_______________________________________________________________________
Actual Issue:
Recently while working on Sitecore 10.3 noticed that when I add the in-built SXA image component to Experience Editor, the image wasn't loading. I did all possible things like running around the computer 2.5 times, jumping-jacks for 19.75 times etc. but nothing worked. Only later I realised that SXA Image component has rendering problems right from good old days.
References:
https://sitecore.stackexchange.com/questions/34871/images-not-loading-in-sxa-site
https://sitecore.stackexchange.com/questions/16012/sxa-image-not-show
Now, with that background, I noticed that i hadn't even set any theme for my site. So, I'm writing here the hack I followed to see the image component appear in my XPE as well as the web page. Now, we can't tell the end-users to do such hacks so take this note with a pinch of salt until you find something permanent to resolve the issue.
First, the problem:
1. Install a Sitecore SXA 10.3 instance
2. Do usual shenanigans of:
- Create a tenant
- Create a Site within it
3. Open the XPE for the site' page:
4. Select image control from toolbox and add to the main placeholder
5. Next,
- Choose an Image
- Upload Media -> Browse for Media Files -> Select file from file system -> provide alt text -> Change Destination to Site location in media library and confirm as follows:
Hack no. 2: This also works but not the Sitecore approach:
Source field by default in Image field template points to query:$siteMedia
Change the Source to a path in themes image folder (as below) and then you should be able to add an image in XPE and the image will be reflected right-away:
Comments
Post a Comment