Liferay动态数据列表:如何获取图像URL? [英] Liferay Dynamic Data Lists: How to get image URL?
本文介绍了Liferay动态数据列表:如何获取图像URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在为动态数据列表快速创建一个自定义模板,我想获取所选图像的图像URL.我怎么能得到它?
I am creating a custom template in velocity for a Dynamic Data Lists and I want to get the image URL for the selected image. How can I get it?
代码是:
#set ( $DDLRecordService = $serviceLocator.findService("com.liferay.portlet.dynamicdatalists.service.DDLRecordLocalService") )
#set ( $records = $DDLRecordService.getRecords($mathTool.toNumber($reserved_record_set_id)) )
#foreach ($record in $records)
#set( $fields = $record.getFields() )
#set( $URL = $fields.get("URL").getValue() )
#set( $Link = $fields.get("Linktitle").getValue() )
#set( $Preview = $fields.get("Vorschaubild").getValue() ) ##the image is here
$URL
$Link
$Preview
#end
$preview
输出为:{"groupId":"0000000","uuid":"ccdaccec-00a0-4284-a000-589be4899281","version":"1.0"}
有什么建议吗?
推荐答案
I also came across similar situation and after searching on the internet for hour(s), didn't find any useful information apart from LPS-34792 ticket.
好吧,您可以使用以下方法从文档和媒体"字段在UI上呈现图像:
Well, you can render image on the UI from a Documents and Media field using:
<#assign hasPicture = cur_record.getFieldValue("picture")?has_content>
<#if hasPicture>
<#assign picture = jsonFactoryUtil.createJSONObject(cur_record.getFieldValue("picture"))>
<img src='/documents/${picture.getString("groupId")}/${picture.getString("uuid")}' />
</#if>
其中picture
是字段名称,hasPicture
将检查是否选择了图像.
Where picture
is the name of field and hasPicture
will check if the image was selected.
这篇关于Liferay动态数据列表:如何获取图像URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文