Tribune

Home » Liferay Portal » English » 3. Development

Vista Combinata Vista Piatta Vista ad Albero
Discussioni [ Precedente | Successivo ]
toggle
Dariusz Sawicki
Display custom image - liferay 6.1 GA 1
20 febbraio 2012 6.34
Risposta

Dariusz Sawicki

Punteggio: Regular Member

Messaggi: 164

Data di Iscrizione: 27 marzo 2009

Messaggi recenti

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
14 marzo 2012 17.38
Risposta

Mika Koivisto

LIFERAY STAFF

Punteggio: Liferay Legend

Messaggi: 1512

Data di Iscrizione: 7 agosto 2006

Messaggi recenti

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
14 marzo 2012 17.45
Risposta

Hitoshi Ozawa

Punteggio: Liferay Legend

Messaggi: 7949

Data di Iscrizione: 23 marzo 2010

Messaggi recenti

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
14 marzo 2012 17.59
Risposta

Mika Koivisto

LIFERAY STAFF

Punteggio: Liferay Legend

Messaggi: 1512

Data di Iscrizione: 7 agosto 2006

Messaggi recenti

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
14 marzo 2012 18.17
Risposta

Hitoshi Ozawa

Punteggio: Liferay Legend

Messaggi: 7949

Data di Iscrizione: 23 marzo 2010

Messaggi recenti

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
14 maggio 2012 1.39
Risposta

Davide N. P. Rossi

Punteggio: Junior Member

Messaggi: 55

Data di Iscrizione: 3 luglio 2010

Messaggi recenti

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)
16 maggio 2012 3.25
Risposta

Davide N. P. Rossi

Punteggio: Junior Member

Messaggi: 55

Data di Iscrizione: 3 luglio 2010

Messaggi recenti

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!!!