Skip to content

Commit

Permalink
Merged in thumbnail-size-fix (pull request #17)
Browse files Browse the repository at this point in the history
[sociald] Instead of using the default and the smallest thumbnail size, try to get bigger one. Contributes to JB#6682
  • Loading branch information
Marko Mattila committed May 16, 2013
2 parents f57d398 + 4b0efc4 commit b392bd5
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/facebook/facebookimagesyncadaptor.cpp
Expand Up @@ -220,8 +220,8 @@ void FacebookImageSyncAdaptor::requestData(int accountId, const QString &accessT
queryItems.append(QPair<QString, QString>(QString(QLatin1String("access_token")), accessToken));
url.setQueryItems(queryItems);
}

QNetworkReply *reply = m_fbsa->m_qnam->get(QNetworkRequest(url));

if (reply) {
reply->setProperty("accountId", accountId);
reply->setProperty("accessToken", accessToken);
Expand Down Expand Up @@ -394,6 +394,23 @@ void FacebookImageSyncAdaptor::photosFinishedHandler()
QString updatedTimeStr = photo.value(QLatin1String("updated_time")).toString();
QString photoName = photo.value(QLatin1String("name")).toString();

// Find the correct thumbnail size. The fallback will be the "picture" which usually
// is too small so this is sort of best guess what sizes FB might returns. We can't
// also hardcode the exact sizes here, because we can't be sure that certains sizes
// will stay for ever.
QVariantList images = photo.value(QLatin1String("images")).toList();
for (int j = 0; j < images.size(); j++) {
QVariantMap image = images.at(j).toMap();
qulonglong width = image.value(QLatin1String("width")).toULongLong();
qulonglong height= image.value(QLatin1String("height")).toULongLong();
if (160 <= width && width <= 350 &&
160 <= height && height <= 350) {
thumbnailUrl = image.value(QLatin1String("source")).toString();
break;
}
}


bool ok = false;
int width = photo.value(QLatin1String("width")).toString().toInt(&ok);
int height = photo.value(QLatin1String("height")).toString().toInt(&ok);
Expand Down

0 comments on commit b392bd5

Please sign in to comment.