Liferay 6.2 如何显示存储在文档和媒体中的图像
Liferay 6.2 How to display images stored in Documents and Media
我想知道在自定义 portlet 的 jsp 中显示 DLFileEntry 图像的所有可能方式。
更具体地说,我目前使用以下方式,但我对 'largeimageid'
的值为零的 DLFileEntry 对象有一些问题
DLFileEntry image = DLFileEntryLocalServiceUtil.getFileEntry(long_id);
String imageUrl = themeDisplay.getPathImage() + "/image_gallery?img_id=" + image.getLargeImageId() + "&t=" + WebServerServletTokenUtil.getToken(image.getLargeImageId());
在不使用大图像 ID 的情况下获取图像 url 的备选方案有哪些?
我想这对你有帮助
<%@ page import="com.liferay.portlet.documentlibrary.model.DLFolder" %>
<%@ page import="com.liferay.portlet.documentlibrary.service.DLFolderLocalServiceUtil" %>
<%@ page import="com.liferay.portlet.documentlibrary.service.DLFileEntryLocalServiceUtil" %>
<%@ page import="com.liferay.portlet.documentlibrary.model.DLFileEntry" %>
<%@ page import="java.util.List" %>
<%@ page import="com.liferay.portlet.imagegallery.service.IGImageLocalServiceUtil" %>
<%@ page import="com.liferay.portlet.imagegallery.model.IGImage" %>
<%@ include file="init.jsp" %>
<%
String igFolderId = portletPreferences.getValue("igFolderId", "0");
String cycleSpeed = portletPreferences.getValue("cycleSpeed", "1000");
String fxSpeed = portletPreferences.getValue("fxSpeed", "1000");
String type = portletPreferences.getValue("type", "fade");
String height = portletPreferences.getValue("height", "480");
String width = portletPreferences.getValue("width", "640");
List<IGImage> images = IGImageLocalServiceUtil.getImages(Long.valueOf(igFolderId));
%>
<c:choose>
<c:when test="<%= Long.valueOf(igFolderId) != 0%>">
<div id="<portlet:namespace />images">
<%
for (int i = 0; i < images.size(); i++) {
IGImage image = images.get(i);
%>
<img width="<%= width %>" height="<%= height %>" src="/image/image_gallery?img_id=<%=image.getLargeImageId()%>" alt="<%=image.getDescription()%>" <%= i == 0 ? "" : "style=\"display:none;\""%>/>
<%
}
%>
</div>
</c:when>
<c:otherwise>
<span class="portlet-msg-info">
Please configure this portlet.
</span>
</c:otherwise>
</c:choose>
<script type="text/javascript">
jQuery(
function() {
jQuery("#<portlet:namespace />images").cycle({
fx: '<%= type %>',
speed: <%= fxSpeed %>,
timeout: <%= cycleSpeed %>
});
}
);
</script>
您好!
以下是与 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)
将 return 您基于 URL 您的门户基于 httpServletRequest
,System.currentTimeMillis()
将为您提供当前时间(毫秒),并且其余参数都可以通过 DLFileEntry
对象获得。
我想知道在自定义 portlet 的 jsp 中显示 DLFileEntry 图像的所有可能方式。 更具体地说,我目前使用以下方式,但我对 'largeimageid'
的值为零的 DLFileEntry 对象有一些问题DLFileEntry image = DLFileEntryLocalServiceUtil.getFileEntry(long_id);
String imageUrl = themeDisplay.getPathImage() + "/image_gallery?img_id=" + image.getLargeImageId() + "&t=" + WebServerServletTokenUtil.getToken(image.getLargeImageId());
在不使用大图像 ID 的情况下获取图像 url 的备选方案有哪些?
我想这对你有帮助
<%@ page import="com.liferay.portlet.documentlibrary.model.DLFolder" %>
<%@ page import="com.liferay.portlet.documentlibrary.service.DLFolderLocalServiceUtil" %>
<%@ page import="com.liferay.portlet.documentlibrary.service.DLFileEntryLocalServiceUtil" %>
<%@ page import="com.liferay.portlet.documentlibrary.model.DLFileEntry" %>
<%@ page import="java.util.List" %>
<%@ page import="com.liferay.portlet.imagegallery.service.IGImageLocalServiceUtil" %>
<%@ page import="com.liferay.portlet.imagegallery.model.IGImage" %>
<%@ include file="init.jsp" %>
<%
String igFolderId = portletPreferences.getValue("igFolderId", "0");
String cycleSpeed = portletPreferences.getValue("cycleSpeed", "1000");
String fxSpeed = portletPreferences.getValue("fxSpeed", "1000");
String type = portletPreferences.getValue("type", "fade");
String height = portletPreferences.getValue("height", "480");
String width = portletPreferences.getValue("width", "640");
List<IGImage> images = IGImageLocalServiceUtil.getImages(Long.valueOf(igFolderId));
%>
<c:choose>
<c:when test="<%= Long.valueOf(igFolderId) != 0%>">
<div id="<portlet:namespace />images">
<%
for (int i = 0; i < images.size(); i++) {
IGImage image = images.get(i);
%>
<img width="<%= width %>" height="<%= height %>" src="/image/image_gallery?img_id=<%=image.getLargeImageId()%>" alt="<%=image.getDescription()%>" <%= i == 0 ? "" : "style=\"display:none;\""%>/>
<%
}
%>
</div>
</c:when>
<c:otherwise>
<span class="portlet-msg-info">
Please configure this portlet.
</span>
</c:otherwise>
</c:choose>
<script type="text/javascript">
jQuery(
function() {
jQuery("#<portlet:namespace />images").cycle({
fx: '<%= type %>',
speed: <%= fxSpeed %>,
timeout: <%= cycleSpeed %>
});
}
);
</script>
您好!
以下是与 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)
将 return 您基于 URL 您的门户基于 httpServletRequest
,System.currentTimeMillis()
将为您提供当前时间(毫秒),并且其余参数都可以通过 DLFileEntry
对象获得。