Gravatar for jason.wilkerson@rbaconsulting.com

Question by jason_wilkerson, Jun 8, 2015 12:29 AM

Displaying images from an index

If I have this value from a Sitecore field ('featured image') in my index, how do I display the image itself?

<image mediaid="{BB64A135-F5BC-401C-B87D-F3367529A28F}" />

I tried this just to get the literal string out but couldn't even get that:

<p>{{= raw['@(Model.ToCoveoFieldName("featured image", false))'] }}</p>

Thanks!

Jason

2 Replies
Gravatar for lbergeron@coveo.com

Answer by Luc Bergeron, Jun 8, 2015 8:27 AM

Hi,

The easiest way to get the image URL is to use the ImageUrlComputedField that ships with Coveo for Sitecore. Here is a topic that explain how to use it: https://developers.coveo.com/display/SC201505/Adding+Images+to+Your+Search+Page

I hope this helps

Gravatar for jason.wilkerson@rbaconsulting.com

Answer by jason_wilkerson, Jun 8, 2015 10:36 AM

Thank you very much for that link! It led me directly to the answer.

Using that configuration worked perfectly for all of my indexed items that were images, but for image fields on an indexed item, I had to dig just a little deeper.

Here's an example for a field called Featured Image on one of our templates (for anyone else looking):

<field fieldName="featuredimageUrl" sourceField="Featured Image">Coveo.SearchProvider.ComputedFields.ImageUrlComputedField, Coveo.SearchProviderBase</field>
<field fieldName="featuredimageAlt" sourceField="Featured Image">Coveo.SearchProvider.ComputedFields.ImageAltComputedField, Coveo.SearchProviderBase</field>

Thanks again for the link!

Ask a question