From 5d05c51db250c3d4cd37dbd802fc044890e32412 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20P=C3=B6sel?= Date: Fri, 4 Apr 2014 14:27:34 +0000 Subject: Facebook: Fix size of downloaded avatars (use 50x50 for smaller and 180x180 for bigger) git-svn-id: http://svn.miranda-ng.org/main/trunk@8852 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/FacebookRM/src/avatars.cpp | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) (limited to 'protocols/FacebookRM/src') diff --git a/protocols/FacebookRM/src/avatars.cpp b/protocols/FacebookRM/src/avatars.cpp index 358018219a..f02a4a2e52 100644 --- a/protocols/FacebookRM/src/avatars.cpp +++ b/protocols/FacebookRM/src/avatars.cpp @@ -55,18 +55,32 @@ void FacebookProto::CheckAvatarChange(MCONTACT hContact, std::string image_url) return; bool big_avatars = getBool(FACEBOOK_KEY_BIG_AVATARS, DEFAULT_BIG_AVATARS); - - // We've got url to avatar of default size 32x32px, let's change it to slightly bigger (50x50px) - looks like maximum size for square format - std::tstring::size_type pos = image_url.rfind("/s32x32/"); - if (pos != std::wstring::npos) - image_url = image_url.replace(pos, 8, big_avatars ? "/s200x200/" : "/s50x50/"); - - if (big_avatars) - { - pos = image_url.rfind("_q."); - if (pos != std::wstring::npos) - image_url = image_url.replace(pos, 3, "_s."); + + // We've got url to avatar of default size 32x32px, let's change it to bigger one + std::tstring::size_type pos, pos2; + + // Remove cropping and use bigger size + pos = image_url.find("/t1.0-1/"); + if (pos != std::tstring::npos) { + pos += 8; + + pos2 = image_url.find("/", pos); + if (pos2 != std::tstring::npos && image_url.find("/", pos2 + 1) != std::tstring::npos) + pos2 = image_url.find("/", pos2 + 1); + + // TODO: crop it somehow to square image + + if (pos2 != std::tstring::npos) + image_url.replace(pos, pos2 - pos, big_avatars ? "p180x180" : "p50x50"); } + + // Allow big images + pos = image_url.rfind("_s."); + if (pos == std::tstring::npos) + pos = image_url.rfind("_t."); + + if (pos != std::tstring::npos) + image_url = image_url.replace(pos, 3, "_q."); DBVARIANT dbv; bool update_required = true; -- cgit v1.2.3