RE: Search Results Template - show image in search results

Paweł Kania, modified 4 Years ago. New Member Post: 1 Join Date: 2/18/21 Recent Posts

Hi.

I am using version 7.3.5 GA6.

I am just creating a custom Widget Template (Search Results Template) for search results. I am trying to display an image, but unfortunately unsuccessful. I used the code that is already in Liferay, but it doesn't work either. Below is the code:

<div>
    <#if entries?has_content>.
    <#list entries as entry>.
             <div>
                ${entry.getThumbnailURLString()}
            </div>
    </#list>
</#if>
</div>

Web content contains an image in the "FEATURED IMAGE" section. What exactly do I need to do to make the image appear in the search results?

thumbnail
Sushil Patidar, modified 4 Years ago. Expert Posts: 467 Join Date: 10/31/11 Recent Posts

Hi,

 

This is abstract image or structure field?

 

Regards

Sushil

thumbnail
Mohammed Yasin, modified 4 Years ago. Liferay Master Posts: 593 Join Date: 8/8/14 Recent Posts

Hi ,

You may need to fetch the image from article object , you can use service locator for fetching the journal article and then use the image .

<#assign journalArticleLocalService = serviceLocator.findService("com.liferay.journal.service.JournalArticleLocalService") />

<#if entries?has_content>
	<#list entries as entry>         
	    <img src="${journalArticleLocalService.getLatestArticle(entry.getClassPK()).getArticleImageURL(themeDisplay)}" />	
	</#list>
</#if>