2016-04-26 97 views
1

我想知道在定製portlet的jsp中顯示DLFileEntry圖像的所有可能方式。 更具體地說,我目前使用下面的方法,但我有一個包含了對「largeimageid」Liferay 6.2如何顯示存儲在文檔和介質中的圖像

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

哪些是獲得圖像URL,而不使用大型圖片ID的替代零個值DLFileEntry對象的一些問題?

回答

5

以下是類似於用於支持Liferay 性文件之一,媒體格局門戶:

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對象獲得。

0

,我認爲這可以幫助你

<%@ 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> 

問候!

+0

您發佈的內容包含大圖像ID:img_id = <%= image.getLargeImageId()%>這是我想要在顯示圖像時避免的一個。再次檢查我的問題。 – jkonst

相關問題