Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
chirag @ India
getting images from document and media folder using structure and template
March 25, 2013 2:08 AM
Answer

chirag @ India

Rank: Regular Member

Posts: 129

Join Date: December 20, 2011

Recent Posts

liferay 6.0 and below have image gallery and document different portlet ,so i used below code to display images from particular folder ,but in liferay 6.1.1 have document and media instead of image gallery and document.

#set ( $IGFolderLocalService=$serviceLocator.findService("com.liferay.portlet.imagegallery.service.IGFolderLocalService"))
#set ( $IGImageLocalService=$serviceLocator.findService("com.liferay.portlet.imagegallery.service.IGImageLocalService"))
#set ($symbolsFolder = $IGFolderLocalService.getFolder($getterUtil.getLong($groupId),0,"$foldername.getData()"))
#if($symbolsFolder)
#set ($symbolImages = $IGImageLocalService.getImages($getterUtil.getLong($groupId),$getterUtil.getLong($symbolsFolder.getFolderId())) )
<div id="gallery1" class="gallery" style="width:$w;">
#foreach( $symbol in $symbolImages )

<ul >
<a href="/image/image_gallery?uuid=$symbol.Uuid&groupId=$groupId" title="$symbol.getName()" >
<li >
<img class="picture" src="/image/image_gallery?img_id=$symbol.getSmallImageId()"/>
</li > </a>
<li class="imgtitle">$symbol.getName()
</li>

</ul>

#end
</div>
#else
No images in folder "$foldername.getData()"
#end

So my problem is how to get images from folder in liferay 6.1.x+.

i try to implement but still not success

#set ($DLAppServiceUtil = $serviceLocator.findService("com.liferay.portlet.documentlibrary.service.DLAppService"))

This service is used to access document and media

Help me out from this problem
Oliver Bayer
RE: getting images from document and media folder using structure and templ
March 25, 2013 2:15 AM
Answer

Oliver Bayer

Rank: Liferay Master

Posts: 870

Join Date: February 18, 2009

Recent Posts

Hi Chiraq,

you should be able to use "Dl*LocalService" (dl = document library) services instead.

HTH Oli
chirag @ India
RE: getting images from document and media folder using structure and templ
March 25, 2013 2:31 AM
Answer

chirag @ India

Rank: Regular Member

Posts: 129

Join Date: December 20, 2011

Recent Posts

holo oliver,

I try my best and i do below code,but there is one problem to find out repository Id in velocity,if you know then tell me or give me any hint...

#set ($DLAppServiceUtil = $serviceLocator.findService("com.liferay.portlet.documentlibrary.service.DLAppService"))
#set ($symbolsFolder = $DLAppServiceUtil.getFolder($getterUtil.getLong($groupId),0,"$foldername.getData()"))

#set($gid = $getterUtil.getLong($request.get("theme-display").get("scope-group-id")))
$getterUtil.getLong($symbolsFolder.getFolderId())
#if($symbolsFolder)
#set ($symbolImages = $DLAppServiceUtil.getFileEntries($repository Id,$getterUtil.getLong($symbolsFolder.getFolderId())))
How to get Repository Id ????
chirag @ India
RE: getting images from document and media folder using structure and templ
March 25, 2013 11:05 PM
Answer

chirag @ India

Rank: Regular Member

Posts: 129

Join Date: December 20, 2011

Recent Posts

chirag dashalaniya:
holo oliver,

I try my best and i do below code,but there is one problem to find out repository Id in velocity,if you know then tell me or give me any hint...

#set ($DLAppServiceUtil = $serviceLocator.findService("com.liferay.portlet.documentlibrary.service.DLAppService"))
#set ($symbolsFolder = $DLAppServiceUtil.getFolder($getterUtil.getLong($groupId),0,"$foldername.getData()"))

#set($gid = $getterUtil.getLong($request.get("theme-display").get("scope-group-id")))
$getterUtil.getLong($symbolsFolder.getFolderId())
#if($symbolsFolder)
#set ($symbolImages = $DLAppServiceUtil.getFileEntries($repository Id,$getterUtil.getLong($symbolsFolder.getFolderId())))
How to get Repository Id ????



Finally i succeed to get images from document and media folder and this is code for that

#set ($DLAppServiceUtil = $serviceLocator.findService("com.liferay.portlet.documentlibrary.service.DLAppService"))
#set ($symbolsFolder = $DLAppServiceUtil.getFolder($getterUtil.getLong($groupId),0,"$foldername.getData()"))
#set($gid = $getterUtil.getLong($request.get("theme-display").get("scope-group-id")))

#if($symbolsFolder)
#set ($symbolImages = $DLAppServiceUtil.getFileEntries($getterUtil.getLong($symbolsFolder.getRepositoryId()),$getterUtil.getLong($symbolsFolder.getFolderId())))
<div id="gallery1" class="gallery" style="width:$w;">
#foreach( $symbol in $symbolImages )
<ul>
#set ($dlService = $serviceLocator.findService("com.liferay.portlet.documentlibrary.service.DLFileEntryLocalService"))
#set ($dlfile = $dlService.getFileEntryByUuidAndGroupId($symbol.getUuid(),$gid))
#set ($filename = $dlfile.getName())



<a href="/documents/$symbolsFolder.getRepositoryId()/$getterUtil.getLong($symbolsFolder.getFolderId())/$dlfile.getName()/$symbol.getUuid()">
<li >
<img class="picture" src="/documents/$symbolsFolder.getRepositoryId()/$getterUtil.getLong($symbolsFolder.getFolderId())/$dlfile.getName()/$symbol.getUuid()""/>
</li > </a>
<li class="imgtitle">
</li>

</ul>

#end
</div>
#else
No images in folder "$foldername.getData()"
#end

help you...
Jitendra Rajput
RE: getting images from document and media folder using structure and templ
March 25, 2013 11:27 PM
Answer

Jitendra Rajput

Rank: Liferay Master

Posts: 674

Join Date: January 7, 2011

Recent Posts

Check for the mime type of DLFileEntry if its any of the below then file is image only.
1image/bmp,image/gif,image/jpeg,image/png,image/tiff,image/x-ms-bmp,image/x-tiff


You can get mime type using below method.
1fileEntry.getMimeType()