Foros de discusión

Display custom image - liferay 6.1 GA 1

Dariusz Sawicki, modificado hace 12 años.

Display custom image - liferay 6.1 GA 1

Regular Member Mensajes: 165 Fecha de incorporación: 27/03/09 Mensajes recientes
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
thumbnail
Mika Koivisto, modificado hace 12 años.

RE: Display custom image - liferay 6.1 GA 1

Liferay Legend Mensajes: 1519 Fecha de incorporación: 7/08/06 Mensajes recientes
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.
thumbnail
Hitoshi Ozawa, modificado hace 12 años.

RE: Display custom image - liferay 6.1 GA 1

Liferay Legend Mensajes: 7942 Fecha de incorporación: 24/03/10 Mensajes recientes
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.
thumbnail
Mika Koivisto, modificado hace 12 años.

RE: Display custom image - liferay 6.1 GA 1

Liferay Legend Mensajes: 1519 Fecha de incorporación: 7/08/06 Mensajes recientes
The settings aren't obsolete. At least the dl.file.entry ones. I didn't see any ig.image.xx ones in there.
thumbnail
Hitoshi Ozawa, modificado hace 12 años.

RE: Display custom image - liferay 6.1 GA 1

Liferay Legend Mensajes: 7942 Fecha de incorporación: 24/03/10 Mensajes recientes
Sorry, it was the uri issue. Need my 3 cups of coffee before I can begin thinking. emoticon
thumbnail
Davide Rossi, modificado hace 11 años.

RE: Display custom image - liferay 6.1 GA 1

Junior Member Mensajes: 55 Fecha de incorporación: 3/07/10 Mensajes recientes
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
dl.file.entry.thumbnail.custom1.max.height=400
dl.file.entry.thumbnail.custom1.max.width=400

dl.file.entry.thumbnail.custom2.max.height=600
dl.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:
<!--?xml version="1.0"?-->
<root>
	<dynamic-element name="Image" type="document_library" index-type="" repeatable="false" />
</root>


The tempate code contains:
#set ($newImage = $Image.getData())

<a href="$newImage" target="_blank"><img alt="" src="$newImage"></a>
<a href="$newImage" target="_blank"><img alt="" src="$newImage+&amp;imageThumbnail=1"></a>
<a href="$newImage" target="_blank"><img alt="" src="$newImage+&amp;imageThumbnail=2"></a>
<a href="$newImage" target="_blank"><img alt="" src="$newImage+&amp;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

if (imageId == dlFileEntry.getSmallImageId()) {
	queryString = "&amp;imageThumbnail=1";
}
else if (imageId == dlFileEntry.getSmallImageId()) {
	queryString = "&amp;imageThumbnail=2";
}
else if (imageId == dlFileEntry.getSmallImageId()) {
	queryString = "&amp;imageThumbnail=3";
}


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
thumbnail
Davide Rossi, modificado hace 11 años.

RE: Display custom image - liferay 6.1 GA 1 (SOLVED)

Junior Member Mensajes: 55 Fecha de incorporación: 3/07/10 Mensajes recientes
Downloaded latest 6.1.x git Source
Compiled
Edited tomcat/webapps/WEB-INF/classes/portal-ext.properties
added below lines:
dl.file.entry.thumbnail.custom1.max.height=400
dl.file.entry.thumbnail.custom1.max.width=400
dl.file.entry.thumbnail.custom2.max.height=600
dl.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:
<!--?xml version="1.0"?-->
<root>
    <dynamic-element name="Image" type="document_library" index-type="" repeatable="false" />
</root>



The tempate code contains:
#set ($newImage = $Image.getData())

<a href="$newImage" target="_blank"><img alt="" src="$newImage"></a>
<a href="$newImage" target="_blank"><img alt="" src="$newImage+&amp;imageThumbnail=1"></a>
<a href="$newImage" target="_blank"><img alt="" src="$newImage+&amp;imageThumbnail=2"></a>
<a href="$newImage" target="_blank"><img alt="" src="$newImage+&amp;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!!!