diff --git a/Telegram/SourceFiles/history/view/media/history_view_extended_preview.cpp b/Telegram/SourceFiles/history/view/media/history_view_extended_preview.cpp index 88c405d2eb..582e952652 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_extended_preview.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_extended_preview.cpp @@ -163,6 +163,9 @@ QSize ExtendedPreview::countCurrentSize(int newWidth) { _parent->textualMaxWidth()); newWidth = qMin(qMax(newWidth, maxWithCaption), thumbMaxWidth); } + if (newWidth >= maxWidth()) { + newHeight = qMin(newHeight, minHeight()); + } return { newWidth, newHeight }; } diff --git a/Telegram/SourceFiles/history/view/media/history_view_photo.cpp b/Telegram/SourceFiles/history/view/media/history_view_photo.cpp index ed0ded0fea..9c5ccd302d 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_photo.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_photo.cpp @@ -218,7 +218,6 @@ QSize Photo::countCurrentSize(int newWidth) { maxWidth()); newWidth = qMax(pix.width(), minWidth); auto newHeight = qMax(pix.height(), st::minPhotoSize); - auto imageHeight = newHeight; if (_parent->hasBubble()) { auto captionMaxWidth = _parent->textualMaxWidth(); const auto botTop = _parent->Get(); @@ -227,10 +226,13 @@ QSize Photo::countCurrentSize(int newWidth) { } const auto maxWithCaption = qMin(st::msgMaxWidth, captionMaxWidth); newWidth = qMin(qMax(newWidth, maxWithCaption), thumbMaxWidth); - imageHeight = newHeight = adjustHeightForLessCrop( + newHeight = adjustHeightForLessCrop( dimensions, { newWidth, newHeight }); } + if (newWidth >= maxWidth()) { + newHeight = qMin(newHeight, minHeight()); + } const auto enlargeInner = st::historyPageEnlargeSize; const auto enlargeOuter = 2 * st::historyPageEnlargeSkip + enlargeInner; const auto showEnlarge = (_parent->media() != this) @@ -238,7 +240,7 @@ QSize Photo::countCurrentSize(int newWidth) { && _parent->data()->media()->webpage() && _parent->data()->media()->webpage()->suggestEnlargePhoto() && (newWidth >= enlargeOuter) - && (imageHeight >= enlargeOuter); + && (newHeight >= enlargeOuter); _showEnlarge = showEnlarge ? 1 : 0; return { newWidth, newHeight }; }