From 7038185e97982e8423388449bb202ff5902e1445 Mon Sep 17 00:00:00 2001 From: Bionus Date: Tue, 30 Apr 2024 22:50:54 +0200 Subject: [PATCH] fix: default %ext% to the model value if file_url does not have any (fix #3142) --- src/lib/src/models/image.cpp | 9 ++++++++- src/lib/src/models/image.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/lib/src/models/image.cpp b/src/lib/src/models/image.cpp index df050ed75..1f1602699 100644 --- a/src/lib/src/models/image.cpp +++ b/src/lib/src/models/image.cpp @@ -232,6 +232,7 @@ Image::Image(Site *site, QMap details, QVariantMap identity, Q const QString realExt = details["ext"]; if (ext != realExt) { setFileExtension(realExt); + m_extension = realExt; } } else if (ext == QLatin1String("jpg") && !url(Size::Thumbnail).isEmpty()) { bool fixed = false; @@ -899,7 +900,13 @@ Page *Image::page() const { return m_parent; } const QUrl &Image::parentUrl() const { return m_parentUrl; } bool Image::isGallery() const { return m_isGallery; } ExtensionRotator *Image::extensionRotator() const { return m_extensionRotator; } -QString Image::extension() const { return getExtension(m_url).toLower(); } +QString Image::extension() const { + QString urlExt = getExtension(m_url).toLower(); + if (!urlExt.isEmpty()) { + return urlExt; + } + return m_extension; +} void Image::setPromoteDetailParsWarn(bool val) { m_detailsParsWarnAsErr = val; } void Image::setPreviewImage(const QPixmap &preview) diff --git a/src/lib/src/models/image.h b/src/lib/src/models/image.h index 27c7e5fa5..952dd769f 100644 --- a/src/lib/src/models/image.h +++ b/src/lib/src/models/image.h @@ -143,6 +143,7 @@ class Image : public QObject, public Downloadable Profile *m_profile; Page *m_parent = nullptr; QUrl m_url; + QString m_extension; QUrl m_pageUrl; QUrl m_parentUrl; QSettings *m_settings;