Liferay模板获取头像
Liferay template get profile picture
你好,我正在使用 Freemarker,我必须获取用户的个人资料图片,我有带有 portraitId 的对象用户,但我不知道如何获取主题显示以获取路径或其他内容...我试过使用这个:
src="/image/user_male_portrait?img_id=${user.getPortraitId()}&img_id_token="
但是我拿不到令牌,因为我不知道:(
<#assign UserLocalService = serviceLocator.findService("com.liferay.portal.service.UserLocalService")>
<#assign user = UserLocalService.getUserById(27132)>
有人知道如何在 freemarker 中获取头像吗?
我认为 themeDisplay
对象已经存在于 liferay freemarker 中。所以你可以直接调用它。
此外 user
对象也有一个方法 getPortraitUrl()
可以调用它来直接获取用户的图像。
您可以通过
检索用户
<#assign user = themeDisplay.getUser() />
然后像这样显示个人资料图片(在 Liferay 中也称为肖像,但通常称为头像)
<img src="${user.getPortraitURL(themeDisplay)}">
你好,我正在使用 Freemarker,我必须获取用户的个人资料图片,我有带有 portraitId 的对象用户,但我不知道如何获取主题显示以获取路径或其他内容...我试过使用这个:
src="/image/user_male_portrait?img_id=${user.getPortraitId()}&img_id_token="
但是我拿不到令牌,因为我不知道:(
<#assign UserLocalService = serviceLocator.findService("com.liferay.portal.service.UserLocalService")>
<#assign user = UserLocalService.getUserById(27132)>
有人知道如何在 freemarker 中获取头像吗?
我认为 themeDisplay
对象已经存在于 liferay freemarker 中。所以你可以直接调用它。
此外 user
对象也有一个方法 getPortraitUrl()
可以调用它来直接获取用户的图像。
您可以通过
检索用户<#assign user = themeDisplay.getUser() />
然后像这样显示个人资料图片(在 Liferay 中也称为肖像,但通常称为头像)
<img src="${user.getPortraitURL(themeDisplay)}">