Fix photo inline result sending.

Fixes #5594.
This commit is contained in:
John Preston 2019-03-12 13:49:16 +04:00
parent 4ebf6ebb6f
commit 2a3a38531b
2 changed files with 12 additions and 11 deletions

View File

@ -1731,26 +1731,27 @@ void Session::photoConvert(
PhotoData *Session::photoFromWeb(
const MTPWebDocument &data,
ImagePtr thumbnailSmall,
ImagePtr thumbnail,
bool willBecomeNormal) {
const auto large = Images::Create(data);
const auto thumbnailInline = ImagePtr();
if (large->isNull()) {
return nullptr;
}
auto thumbnail = large;
auto thumbnailSmall = large;
if (willBecomeNormal) {
const auto width = large->width();
const auto height = large->height();
if (thumbnailSmall->isNull()) {
auto thumbsize = shrinkToKeepAspect(width, height, 100, 100);
thumbnailSmall = Images::Create(thumbsize.width(), thumbsize.height());
}
if (thumbnail->isNull()) {
auto mediumsize = shrinkToKeepAspect(width, height, 320, 320);
thumbnail = Images::Create(mediumsize.width(), mediumsize.height());
} else if (thumbnailSmall->isNull()) {
thumbnailSmall = large;
}
} else if (thumbnail->isNull()) {
thumbnail = large;
}
return photo(

View File

@ -355,7 +355,7 @@ public:
const MTPPhoto &data);
[[nodiscard]] PhotoData *photoFromWeb(
const MTPWebDocument &data,
ImagePtr thumbnailSmall = ImagePtr(),
ImagePtr thumbnail = ImagePtr(),
bool willBecomeNormal = false);
[[nodiscard]] not_null<DocumentData*> document(DocumentId id);