Liferay 6.2如何显示存储在文档和媒体中的图像

jko*_*nst 2 liferay liferay-6

我想知道在自定义portlet的jsp中显示DLFileEntry映像的所有可能方法.更具体地说,我目前使用以下方式,但我有一些DLFileEntry对象的问题,'bigimageid'的值为零

DLFileEntry image = DLFileEntryLocalServiceUtil.getFileEntry(long_id);
String imageUrl = themeDisplay.getPathImage() + "/image_gallery?img_id=" + image.getLargeImageId() +  "&t=" + WebServerServletTokenUtil.getToken(image.getLargeImageId());
Run Code Online (Sandbox Code Playgroud)

哪个是在不使用大图像ID的情况下获取图像网址的替代方法?

Par*_*mar 5

以下是类似于Liferay Documents and Media portlet使用的模式:

DLFileEntry image = DLFileEntryLocalServiceUtil.getFileEntry(long_id);
String imageUrl = "";
if (image != null) {
    imageUrl =
        PortalUtil.getPortalURL(request) + "/documents/" + image.getGroupId() + "/" +
            image.getFolderId() + "/" + image.getTitle() + "/" + image.getUuid() + "?t=" +
            System.currentTimeMillis();
}
Run Code Online (Sandbox Code Playgroud)

哪里PortalUtil.getPortalURL(request)会返回您的门户基础URL httpServletRequest,System.currentTimeMillis()将给您当前时间(毫秒),其余参数都可以通过DLFileEntry对象获得.