Disper
Disper

Reputation: 745

Get access and render document's image in Liferay's Display Template

I'm using Liferay 6.2 CE and I would like create a very simple Application Display Template for Asset Publisher which would display only one image without any additional metadata. The purpose of this is to allow page admin to just drag and drop an existing document (which contains only an image) that would e.g. fill entire column on a page.

My problem is that I don't know how to access this image.

I would like to do something like this:

<#assign img=renderRequest.getImageUrl()>
<img url="{$img}" />

I've used freemarker to list all attributes

<#assign x=renderRequest.getAttributeNames()>

<#list x as item>
    <br/>
    ${item}
</#list>

which gave me the result:

LAST_PATH
FRIENDLY_URL
liferay-ui:success:message
javax.servlet.forward.context_path
RENDER_PORTLET_COLUMN_ID
PORTLET_AJAX_RENDER
com.liferay.portal.servlet.filters.gzip.GZipFilterSKIP_FILTER
THEME
javax.servlet.forward.servlet_path
javax.portlet.config
RENDER_PORTLET_COLUMN_POS
liferay-ui:error:rowBreak
org.apache.struts.action.MODULE
javax.portlet.response
COMPANY
javax.servlet.forward.query_string
bodyContent
javax.servlet.forward.path_info
com.liferay.portal.servlet.filters.i18n.I18nFilterSKIP_FILTER
User-Agent
view.jsp-results
INVOKER_FILTER_URI
liferay-ui:error:translateMessage
com.liferay.portal.kernel.util.CookieKeys
javax.servlet.include.context_path
dynamicAttributes
javax.portlet.lifecycle_phase
VIRTUAL_HOST_LAYOUT_SET
liferay-ui:success:key
scopedAttributes
javax.servlet.include.servlet_path
javax.servlet.forward.request_uri
COLOR_SCHEME
PORTLET_STRUTS_ACTION
liferay-ui:error:message
liferay-ui:success:translateMessage
LIFERAY_SHARED_SEARCH_CONTAINER_REFERENCE
LIFERAY_SHARED_THEME_DISPLAY
WINDOW_STATE
CURRENT_COMPLETE_URL
SERVLET_CONTEXT_INCLUDE_FILTER_STRICT
javax.servlet.include.request_uri
com.liferay.portal.servlet.filters.strip.StripFilterSKIP_FILTER
ACCEPT
LAYOUT
RENDER_PORTLET
USER_ID
org.apache.struts.taglib.tiles.CompContext
COMPANY_ID
USER
LAYOUTS
RENDER_PORTLET_COLUMN_COUNT
PORTLET_PARALLEL_RENDER
liferay-ui:error:key
PORTLET_ID
com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterSECURE_RESPONSE
javax.portlet.request
CURRENT_URL
CTX
org.apache.struts.action.mapping.instance 

But I still can't figure out which attribute is responsible for retrieving images... Or is there any other way to achieve this?

Upvotes: 1

Views: 2166

Answers (1)

Mark
Mark

Reputation: 18827

My opinion for this approach you need new Web Content Structure and Web Content Template (and not Application Display Template).

Create new Web Content Structure with only one image field:

enter image description here

enter image description here

Create new Web Content Template:

enter image description here

ans associate structure and template:

enter image description here

Ready:

enter image description here

Upvotes: 3

Related Questions