Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
sawi _
Display custom image - liferay 6.1 GA 1
February 20, 2012 6:34 AM
Answer

sawi _

Rank: Regular Member

Posts: 147

Join Date: March 27, 2009

Recent Posts

Hello
I developed portlet to show custom image.
In 6.1 I try generate custom image by add to portal-ext.properties

dl.file.entry.thumbnail.custom1.max.height=100
dl.file.entry.thumbnail.custom1.max.width=100

dl.file.entry.thumbnail.custom2.max.height=300
dl.file.entry.thumbnail.custom2.max.width=300

-- also i try this
ig.image.custom1.max.dimension=200
ig.image.custom2.max.dimension=70

but on the portlet page i display image object :

{uuid=0d48571a-8bf6-4ec2-9a88-e8d485407dde, fileEntryId=10436, groupId=10180, companyId=10154, userId=10196, userName=Test Test, versionUserId=10196, versionUserName=Test Test, createDate=Mon Feb 20 14:19:32 GMT 2012, modifiedDate=Mon Feb 20 14:19:32 GMT 2012, repositoryId=10180, folderId=10433, name=1, extension=jpg, mimeType=image/jpeg, title=Chrysanthemum.jpg, description=, extraSettings=, fileEntryTypeId=0, version=1.0, size=879394, readCount=1, smallImageId=0, largeImageId=0, custom1ImageId=0, custom2ImageId=0}

and don't know why i don;t have smaill imageId and other "largeImageId=0, custom1ImageId=0, custom2ImageId"

Anybody know what I doing wrong?

Regards
Darek
Mika Koivisto
RE: Display custom image - liferay 6.1 GA 1
March 14, 2012 5:38 PM
Answer

Mika Koivisto

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1499

Join Date: August 7, 2006

Recent Posts

Those are legacy image ids and they are no longer used. You can get custom1 thumbnail by adding &imageThumbnail=1 to the image url. Custom2 would be &imageThumbnail=2. DLUtil.getPreviewURL() will assist you in generating the url.
Hitoshi Ozawa
RE: Display custom image - liferay 6.1 GA 1
March 14, 2012 5:45 PM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7990

Join Date: March 23, 2010

Recent Posts

Mika, it is possible to take these settings out from the portal.properties as well in the next release? It really confuses users and it's a very difficult uphill battle convincing users not to use them when obsolete settings are still there.
Mika Koivisto
RE: Display custom image - liferay 6.1 GA 1
March 14, 2012 5:59 PM
Answer

Mika Koivisto

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1499

Join Date: August 7, 2006

Recent Posts

The settings aren't obsolete. At least the dl.file.entry ones. I didn't see any ig.image.xx ones in there.
Hitoshi Ozawa
RE: Display custom image - liferay 6.1 GA 1
March 14, 2012 6:17 PM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7990

Join Date: March 23, 2010

Recent Posts

Sorry, it was the uri issue. Need my 3 cups of coffee before I can begin thinking. emoticon
Davide N. P. Rossi
RE: Display custom image - liferay 6.1 GA 1
May 14, 2012 1:39 AM
Answer

Davide N. P. Rossi

Rank: Junior Member

Posts: 55

Join Date: July 3, 2010

Recent Posts

Hi to all,
I have spent a while on trying to figure out how custom1 and custom2 images work with no positive result.

I added below lines to portal-ext.properties
1dl.file.entry.thumbnail.custom1.max.height=400
2dl.file.entry.thumbnail.custom1.max.width=400
3
4dl.file.entry.thumbnail.custom2.max.height=600
5dl.file.entry.thumbnail.custom2.max.width=600


After restarting the portal I uploaded a 800px image
I then created a new WebContent structure and template

The structure code contains:
1<?xml version="1.0"?>
2<root>
3    <dynamic-element name="Image" type="document_library" index-type="" repeatable="false"/>
4</root>


The tempate code contains:
1#set ($newImage = $Image.getData())
2
3<A HREF="$newImage" target="_blank"><img alt="" src="$newImage" /></A>
4<A HREF="$newImage" target="_blank"><img alt="" src="$newImage+&imageThumbnail=1" /></A>
5<A HREF="$newImage" target="_blank"><img alt="" src="$newImage+&imageThumbnail=2" /></A>
6<A HREF="$newImage" target="_blank"><img alt="" src="$newImage+&imageThumbnail=3" /></A>


After Creating a Web Content selecting the new uploaded image and previewing I get:
$newImage and $newImage+&imageThumbnail=1 are displayed
$newImage+&imageThumbnail=2 and $newImage+&imageThumbnail=3 are not displayed

Based on the following code found in: ./portal-impl/src/com/liferay/portal/webserver/WebServerServlet.java

 1if (imageId == dlFileEntry.getSmallImageId()) {
 2    queryString = "&imageThumbnail=1";
 3}
 4else if (imageId == dlFileEntry.getSmallImageId()) {
 5    queryString = "&imageThumbnail=2";
 6}
 7else if (imageId == dlFileEntry.getSmallImageId()) {
 8    queryString = "&imageThumbnail=3";
 9}


i expected to get:
original image (800px)
&imageThumbnail=1 (128px)
&imageThumbnail=2 (400px)
&imageThumbnail=3 (600px)

Seems to me that the custom images are not created. Looking through data directory there are only the original image and default thumbnail.

Am I doing something wrong??? Can it be a bug not creating the custom images when uploading??? Please help!

Thanks
Davide N. P. Rossi
RE: Display custom image - liferay 6.1 GA 1 (SOLVED)
May 16, 2012 3:25 AM
Answer

Davide N. P. Rossi

Rank: Junior Member

Posts: 55

Join Date: July 3, 2010

Recent Posts

Downloaded latest 6.1.x git Source
Compiled
Edited tomcat/webapps/WEB-INF/classes/portal-ext.properties
added below lines:
1dl.file.entry.thumbnail.custom1.max.height=400
2dl.file.entry.thumbnail.custom1.max.width=400
3dl.file.entry.thumbnail.custom2.max.height=600
4dl.file.entry.thumbnail.custom2.max.width=600


After starting the portal I uploaded some large images
I then created a new WebContent structure and template

The structure code contains:
1<?xml version="1.0"?>
2<root>
3    <dynamic-element name="Image" type="document_library" index-type="" repeatable="false"/>
4</root>



The tempate code contains:
1#set ($newImage = $Image.getData())
2
3<A HREF="$newImage" target="_blank"><img alt="" src="$newImage" /></A>
4<A HREF="$newImage" target="_blank"><img alt="" src="$newImage+&imageThumbnail=1" /></A>
5<A HREF="$newImage" target="_blank"><img alt="" src="$newImage+&imageThumbnail=2" /></A>
6<A HREF="$newImage" target="_blank"><img alt="" src="$newImage+&imageThumbnail=3" /></A>


After Creating a Web Content selecting the new uploaded image and previewing I get:
ALL FOUR CORRECTLY RESIZED IMAGES

It will work in 6.1.1 GA2

Great Work!!!! Thanks!!!