Liferay Web 内容模板中的图像描述

Image Description in Liferay Web Content Template

在我的 Web 内容结构中,我有一个文档和媒体类型字段,以便用户可以 select 图片。在 Web 内容模板中,我想获取 selected 图像的描述,以便我可以填写图像的替代文本。

如何获取模板中 selected 图片的描述信息?

可以获取描述等字段,需要先获取图片ID。然后您将使用 DLFileEntryLocalServiceUtil 获取文件。获取文件后,您可以调用函数来获取描述。

<#assign imgID = Image.getData()?string?split("/")[5]?split("?")[0]>
<#assign fileEntry = staticUtil["com.liferay.portlet.documentlibrary.service.DLFileEntryLocalServiceUtil"]>
<#assign file=fileEntry.getFileEntryByUuidAndGroupId(imgID, groupId) >

${file.getDescription()}

您可以通过调用 DLFileEntryModel 的其他函数之一来获取 document/image 的其他元数据。