diff --git a/resources/skins/nudus-base/html_style_base.scss b/resources/skins/nudus-base/html_style_base.scss
index 48bdb7c1d..9821a17c4 100644
--- a/resources/skins/nudus-base/html_style_base.scss
+++ b/resources/skins/nudus-base/html_style_base.scss
@@ -391,7 +391,7 @@ summary {
}
}
- .rssguard-mbody img {
+ img {
// Needs to be `!important` when max-width is defined by image style
//
//max-width: 450px !important;
diff --git a/resources/skins/nudus-dark/html_style.css b/resources/skins/nudus-dark/html_style.css
index 9c4394132..784437a75 100644
--- a/resources/skins/nudus-dark/html_style.css
+++ b/resources/skins/nudus-dark/html_style.css
@@ -253,7 +253,7 @@ summary:focus {
.rssguard-mwrapper .rssguard-mhead .mlinks .mwrapurl a[href=""], .rssguard-mwrapper .rssguard-mhead .mlinks .mwrapurl a[href=""] + span {
display: none; }
@media only screen and (max-width: 800px) {
- .rssguard-mwrapper .rssguard-mbody img {
+ .rssguard-mwrapper img {
max-width: 100% !important; } }
.rssguard-mbody {
diff --git a/resources/skins/nudus-light/html_style.css b/resources/skins/nudus-light/html_style.css
index 12ef8da9c..c63af23a7 100644
--- a/resources/skins/nudus-light/html_style.css
+++ b/resources/skins/nudus-light/html_style.css
@@ -253,7 +253,7 @@ summary:focus {
.rssguard-mwrapper .rssguard-mhead .mlinks .mwrapurl a[href=""], .rssguard-mwrapper .rssguard-mhead .mlinks .mwrapurl a[href=""] + span {
display: none; }
@media only screen and (max-width: 800px) {
- .rssguard-mwrapper .rssguard-mbody img {
+ .rssguard-mwrapper img {
max-width: 100% !important; } }
.rssguard-mbody {
diff --git a/src/librssguard/miscellaneous/skinfactory.cpp b/src/librssguard/miscellaneous/skinfactory.cpp
index 2a4ac13a4..17955cd5e 100644
--- a/src/librssguard/miscellaneous/skinfactory.cpp
+++ b/src/librssguard/miscellaneous/skinfactory.cpp
@@ -264,7 +264,8 @@ PreparedHtml SkinFactory::generateHtmlOfArticles(const QList& messages,
enclosure_images +=
skin.m_enclosureImageMarkup.arg(enclosure.m_url,
enclosure.m_mimeType,
- forced_img_height <= 0 ? QString() : QString::number(forced_img_height));
+ forced_img_height <= 0 ? QString::number(-1)
+ : QString::number(forced_img_height));
}
}
}
@@ -315,6 +316,10 @@ PreparedHtml SkinFactory::generateHtmlOfArticles(const QList& messages,
}
}
+#if !defined(NDEBUG)
+ IOFactory::writeFile("c.html", msg_contents.toUtf8());
+#endif
+
return {msg_contents, base_url};
}
diff --git a/src/librssguard/network-web/webfactory.cpp b/src/librssguard/network-web/webfactory.cpp
index 91a734277..863787856 100644
--- a/src/librssguard/network-web/webfactory.cpp
+++ b/src/librssguard/network-web/webfactory.cpp
@@ -263,6 +263,7 @@ QString WebFactory::unescapeHtml(const QString& html) {
QString WebFactory::limitSizeOfHtmlImages(const QString& html, int desired_width, int desired_max_height) const {
static QRegularExpression exp_image_tag(QSL("
]+)>"));
static QRegularExpression exp_image_attrs(QSL("(\\w+)=\"([^\"]+)\""));
+ static bool is_lite = qApp->usingLite();
// Replace too big pictures. What it exactly does:
// - find all
tags and check for existence of height/width attributes:
@@ -275,7 +276,9 @@ QString WebFactory::limitSizeOfHtmlImages(const QString& html, int desired_width
QString my_html = html;
QElapsedTimer tmr;
+#if !defined(NDEBUG)
// IOFactory::writeFile("a.html", html.toUtf8());
+#endif
tmr.start();
@@ -300,38 +303,43 @@ QString WebFactory::limitSizeOfHtmlImages(const QString& html, int desired_width
attrs.insert(attr_name, attr_value);
}
- if (attrs.contains("height") && attrs.contains("width")) {
- double ratio = attrs.value("width").toDouble() / attrs.value("height").toDouble();
+ // Now, we edit height/width differently, depending whether this is
+ // simpler HTML (lite) viewer, or WebEngine full-blown viewer.
+ if (is_lite) {
+ if (attrs.contains("height") && attrs.contains("width")) {
+ double ratio = attrs.value("width").toDouble() / attrs.value("height").toDouble();
- if (desired_max_height > 0) {
- // We limit height.
- attrs.insert("height", QString::number(desired_max_height));
- attrs.insert("width", QString::number(int(ratio * desired_max_height)));
- }
+ if (desired_max_height > 0) {
+ // We limit height.
+ attrs.insert("height", QString::number(desired_max_height));
+ attrs.insert("width", QString::number(int(ratio * desired_max_height)));
+ }
- // We fit width.
- if (attrs.value("width").toInt() > desired_width) {
- attrs.insert("width", QString::number(desired_width));
- attrs.insert("height", QString::number(int(desired_width / ratio)));
+ // We fit width.
+ if (attrs.value("width").toInt() > desired_width) {
+ attrs.insert("width", QString::number(desired_width));
+ attrs.insert("height", QString::number(int(desired_width / ratio)));
+ }
}
- }
- else if (attrs.contains("width")) {
- // Only width.
- if (attrs.value("width").toInt() > desired_width) {
- attrs.insert("width", QString::number(desired_width));
+ else if (attrs.contains("width")) {
+ // Only width.
+ if (attrs.value("width").toInt() > desired_width) {
+ attrs.insert("width", QString::number(desired_width));
+ }
+ }
+ else {
+ // No dimensions given or just height.
+ if (desired_max_height > 0) {
+ attrs.insert("height", QString::number(desired_max_height));
+ }
}
}
else {
- // No dimensions given or just height.
+ attrs.remove("width");
+ attrs.remove("height");
if (desired_max_height > 0) {
- attrs.insert("height", QString::number(desired_max_height));
+ attrs.insert("style", QSL("max-height: %1px !important;").arg(desired_max_height));
}
- /*
- else {
- // We do not know image dimensions and size limitting is not there.
- attrs.insert("width", QString::number(desired_width / 2));
- }cd
- */
}
// Re-insert all attributes.
@@ -359,7 +367,9 @@ QString WebFactory::limitSizeOfHtmlImages(const QString& html, int desired_width
match_offset = exp_match.capturedStart() + img_reconstructed.size();
}
+#if !defined(NDEBUG)
// IOFactory::writeFile("b.html", my_html.toUtf8());
+#endif
qDebugNN << LOGSEC_GUI << "HTML image resizing took" << NONQUOTE_W_SPACE(tmr.elapsed()) << "miliseconds.";
return my_html;