如何在Liferay中检索用户个人资料图片 [英] How to retrieve a user profile picture in Liferay
问题描述
我想检索用户个人资料图片。我该怎么做?你能分享一下代码片段吗?我正在使用Liferay 6.0.6。它只有user.getPortraitId()而没有user.getPortraitURL()。所以一旦我在JAVA课程中获得了肖像ID,我该怎么办呢?
I want to retrieve a user profile picture. How do i do it? Could you please share a code snippet? Im using Liferay 6.0.6. It has only user.getPortraitId() and no user.getPortraitURL(). So once i get the portrait id inside a JAVA class, what do i do with it?
推荐答案
查看<$的实现c $ c> UserConstants.getPortraitURL(...)
https://github.com/liferay/liferay-portal/blob/master/portal-service/src/com/liferay/portal/ model / UserConstants.java
在这种方法中你可以获得图片网址。
On this approach you can get the image url.
如果你需要图片对象,你可以用 ImageLocalServiceUtil
加载它:
If you need the image object, you can load it with ImageLocalServiceUtil
:
long portraitId = user.getPortraitId();
Image image = ImageLocalServiceUtil.getImage(portraitId);
这篇关于如何在Liferay中检索用户个人资料图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!