Liferay 6.2如何显示文档和媒体中存储的图像 [英] Liferay 6.2 How to display images stored in Documents and Media
问题描述
我想知道在自定义portlet的jsp中显示DLFileEntry图像的所有可能方式. 更具体地说,我目前使用以下方式,但DLFileEntry对象的"largeimageid"值为零,则存在一些问题
I would like to know all possible ways of displaying a DLFileEntry image in a jsp of a custom portlet. More specifically, I currently use the following way but I have some issues with DLFileEntry objects that have zero values for 'largeimageid'
DLFileEntry image = DLFileEntryLocalServiceUtil.getFileEntry(long_id);
String imageUrl = themeDisplay.getPathImage() + "/image_gallery?img_id=" + image.getLargeImageId() + "&t=" + WebServerServletTokenUtil.getToken(image.getLargeImageId());
在不使用大图片ID的情况下获取图片网址的替代方法有哪些?
Which are the alternatives of getting the image url without use of the large image id?
推荐答案
以下是与Liferay 文档和媒体 portlet使用的模式相似的模式:
Following is the pattern similar to the one that is used by 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();
}
PortalUtil.getPortalURL(request)
将基于httpServletRequest
返回门户的基本URL,System.currentTimeMillis()
将为您提供当前时间(毫秒),其余参数均可通过DLFileEntry
对象使用.
Where PortalUtil.getPortalURL(request)
will return you base URL of your portal based on httpServletRequest
, System.currentTimeMillis()
will give you current time (miliseconds), and rest of the parameters are all available through DLFileEntry
object.
这篇关于Liferay 6.2如何显示文档和媒体中存储的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!