Topic-icon Avatar deleted from server after social sign-in

Active Subscriptions:

None
HI, i just setup our site with JFBConnect for Facebook and Google.

Our site use Jomsocial, JSPT (from readybytes) and now JFBConnect.

I have three profile types, each one with its default avatar. Default avatars are stored on images/profiletype/avatar_1.png, images/profiletype/avatar_2.png and images/profiletype/avatar_3.png.

Everything works fine, but after a user create and account using his social account (facebook), the default image avatar is removed from the server. That is very annoying.

Help needed.

Regards,
JM
The topic has been locked.
Active Subscriptions:

None
I found this on user's model from jomsocial:

Method setImage
// If old file is default_thumb or default, we should not remove it.
            // Need proper way to test it
            if (!JString::stristr($oldFile, 'components/com_community/assets/default.jpg') && !JString::stristr($oldFile, 'components/com_community/assets/default_thumb.jpg') && $removeOldImage && !JString::stristr($oldFile, 'avatar_')) {
                // File exists, try to remove old files first.
                $oldFile = CString::str_ireplace('/', '/', $oldFile);

                if (JFile::exists($oldFile)) {
                    JFile::delete($oldFile);
                }
            }

But, that's applied only for jomsocial default avatar not for JSPT's profile's avatar images.

So, what can i do?

Regards,
JM
The topic has been locked.
Support Specialist
8 years 10 months ago #62184 by alzander
JM,
There is a block of code where we remove the old avatar for a user, which must be the default in your case, though we haven't had any reports of this happening to other users so just aren't aware of it.

To check, please edit the /plugins/socialprofiles/jomsocial/jomsocial.php file. Around line 623, you should see:
if ($jsUser->save())
        {
            if (JFile::exists(JPATH_SITE . '/' . $currentAvatar))
                JFile::delete(JPATH_SITE . '/' . $currentAvatar);
            if (JFile::exists(JPATH_SITE . '/' . $currentThumb))
                JFile::delete(JPATH_SITE . '/' . $currentThumb);
        }
Delete or comment out that section with /* at the beginning and */ at the end.

Let us know if that fixes the problem. We can look into adding a similar check to the one you posted above as well before deleting the old avatar.

Thanks,
Alex
The topic has been locked.
Active Subscriptions:

None
Hi! Yes, commenting those lines fixed the problem.

Maybe a name convention for default avatars could helps.

We discover a new problem today. I am posting support ticket for that right now.

Thanks and regards,
JM
The topic has been locked.
Support Specialist
8 years 10 months ago #62195 by alzander
JM,
Thanks for the confirmation that the above code was the cause of the problem. We have a to-do list item in our bug tracker to investigate this further along with the original snippet of code you provided. If we can implement this in a way that doesn't introduce other issues, it will definitely be in a future update.

Thanks,
Alex
The topic has been locked.
Active Subscriptions:

None
OK!

Thanks Alex
The topic has been locked.