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 582e952652..9c1a73a64a 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_extended_preview.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_extended_preview.cpp @@ -113,6 +113,10 @@ void ExtendedPreview::unloadHeavyPart() { _spoiler.animation = nullptr; } +bool ExtendedPreview::enforceBubbleWidth() const { + return true; +} + QSize ExtendedPreview::countOptimalSize() { const auto &preview = _invoice->extendedPreview; const auto dimensions = preview.dimensions; diff --git a/Telegram/SourceFiles/history/view/media/history_view_extended_preview.h b/Telegram/SourceFiles/history/view/media/history_view_extended_preview.h index 0e645456ee..da2cd5d14e 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_extended_preview.h +++ b/Telegram/SourceFiles/history/view/media/history_view_extended_preview.h @@ -54,6 +54,7 @@ public: bool hasHeavyPart() const override; void unloadHeavyPart() override; + bool enforceBubbleWidth() const override; private: int minWidthForButton() const; diff --git a/Telegram/SourceFiles/history/view/media/history_view_photo.cpp b/Telegram/SourceFiles/history/view/media/history_view_photo.cpp index db309ee621..2205625d88 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_photo.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_photo.cpp @@ -162,6 +162,10 @@ void Photo::unloadHeavyPart() { togglePollingStory(false); } +bool Photo::enforceBubbleWidth() const { + return true; +} + void Photo::togglePollingStory(bool enabled) const { const auto pollingStory = (enabled ? 1 : 0); if (!_storyId || _pollingStory == pollingStory) { @@ -193,6 +197,9 @@ QSize Photo::countOptimalSize() { auto maxWidth = qMax(maxActualWidth, scaled.height()); auto minHeight = qMax(scaled.height(), st::minPhotoSize); if (_parent->hasBubble()) { + const auto captionMaxWidth = _parent->textualMaxWidth(); + const auto maxWithCaption = qMin(st::msgMaxWidth, captionMaxWidth); + maxWidth = qMin(qMax(maxWidth, maxWithCaption), st::msgMaxWidth); minHeight = adjustHeightForLessCrop( dimensions, { maxWidth, minHeight }); diff --git a/Telegram/SourceFiles/history/view/media/history_view_photo.h b/Telegram/SourceFiles/history/view/media/history_view_photo.h index 8b50f52ac1..44fbed00c7 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_photo.h +++ b/Telegram/SourceFiles/history/view/media/history_view_photo.h @@ -88,6 +88,7 @@ public: bool hasHeavyPart() const override; void unloadHeavyPart() override; + bool enforceBubbleWidth() const override; protected: float64 dataProgress() const override;