Foros de discusión

Delete profile image in custom portlet

thumbnail
Raja Seth, modificado hace 10 años.

Delete profile image in custom portlet

Regular Member Mensajes: 233 Fecha de incorporación: 18/08/11 Mensajes recientes
Hi All,

In my project I am developing user account portlet, somewhat similar to My Account in Liferay control panel. I have used image upload functionality using the below taglib :

<liferay-ui:logo-selector
defaultLogoURL="/my-new-theme/images/img_comment_user.png"
editLogoURL="${editPortraitURL}"
imageId="<%= userProfile.getPortraitId() %>"
logoDisplaySelector=".user-logo"
showBackground="<%= false %>" />


When I uploads the image, it gets uploaded and saved for the user logged in. But for deleting the image, as from control panel we need to save our modifications, similar kind of functionality I want to use on save.

Please let me know if anyone have developed the same thing in custom portlet.

Any help would be appreciated.

Thanks,
Raja
thumbnail
Apoorva Prakash, modificado hace 10 años.

RE: Delete profile image in custom portlet

Liferay Master Mensajes: 658 Fecha de incorporación: 15/06/10 Mensajes recientes
Raja Seth:
Hi All,

In my project I am developing user account portlet, somewhat similar to My Account in Liferay control panel. I have used image upload functionality using the below taglib :

<liferay-ui:logo-selector
defaultLogoURL="/my-new-theme/images/img_comment_user.png"
editLogoURL="${editPortraitURL}"
imageId="<%= userProfile.getPortraitId() %>"
logoDisplaySelector=".user-logo"
showBackground="<%= false %>" />


When I uploads the image, it gets uploaded and saved for the user logged in. But for deleting the image, as from control panel we need to save our modifications, similar kind of functionality I want to use on save.

Please let me know if anyone have developed the same thing in custom portlet.

Any help would be appreciated.

Thanks,
Raja


Hello Raja,

Method is already available in API, see the following:

com.liferay.portal.service.UserLocalServiceUtil.deletePortrait(userId)


HTH.

Thanks and Regards,
Apooorva Prakash
thumbnail
Raja Seth, modificado hace 10 años.

RE: Delete profile image in custom portlet

Regular Member Mensajes: 233 Fecha de incorporación: 18/08/11 Mensajes recientes
Hi Apoorva,

Thanks for your reply. Yes I am aware about this method, but using liferay taglib, I am not able to delete it.

Also, using this method only entry from USER table gets removed not from IMAGE table. But if you check the flow from control panel, it removes from both the places. Correct me if I am wrong!

Please let me know how we can delete the image from taglib.

Thanks,
Raja
Chintan Akhani, modificado hace 10 años.

RE: Delete profile image in custom portlet

Regular Member Mensajes: 111 Fecha de incorporación: 13/03/08 Mensajes recientes
Hi Raja,

"deletePortrait(long userId)" this method will take care of image deletion from Image gallery as well. If you check the implementation of this method in UserLocalServiceImpl than you will find two calls, one is for 'update user' and another one is 'delete image'. So this method should work for you. Please check your logs as well.

Thanks,
Chintan
thumbnail
Raja Seth, modificado hace 10 años.

RE: Delete profile image in custom portlet

Regular Member Mensajes: 233 Fecha de incorporación: 18/08/11 Mensajes recientes
Hi Chintan,

Thanks for your reply. I used this method in my controller :

boolean deleteLogo = ParamUtil.getBoolean(request, "deleteLogo");
if (deleteLogo) {
UserServiceUtil.deletePortrait(user.getUserId());
}


But something strange is happening. When I delete and click on save button from my custom portlet, my profile image is replaced by the liferay logo image. I debugged and found out, My Account in Liferay control panel also calls the same method. Also when I looked into the database, the call from my custom portlet only removes the entry from IMAGE_ table, but doesn't reset's the PORTRAITID in USER_ table. Because of which its displaying the liferay logo image.

Please help me out.

Thanks,
Raja