summaryrefslogtreecommitdiff
path: root/plugins/NewStory/src
diff options
context:
space:
mode:
authorElzorFox <elzorfox@ya.ru>2024-04-27 15:32:08 +0500
committerElzorFox <elzorfox@ya.ru>2024-04-27 15:32:08 +0500
commitbaaf774e98559d0315ca17725b39e48aec37f5a3 (patch)
tree28b418ff98e7e9dd31deb144500ef6c6884b85cd /plugins/NewStory/src
parent7daaae893a1e65daa28ec3a00eb5bdc42d49aa1a (diff)
NewStory:
fix #4342 add height param support for [img=…] bbc
Diffstat (limited to 'plugins/NewStory/src')
-rw-r--r--plugins/NewStory/src/templates.cpp26
1 files changed, 18 insertions, 8 deletions
diff --git a/plugins/NewStory/src/templates.cpp b/plugins/NewStory/src/templates.cpp
index a9535991d1..42fadcd7cf 100644
--- a/plugins/NewStory/src/templates.cpp
+++ b/plugins/NewStory/src/templates.cpp
@@ -45,17 +45,17 @@ static wchar_t* font2html(LOGFONTA &lf, wchar_t *dest)
return dest;
}
-static void AppendImage(CMStringW &buf, const CMStringW &wszUrl, const CMStringW &wszDescr, ItemData *pItem)
+static void AppendImage(CMStringW &buf, const CMStringW &wszUrl, const CMStringW &wszDescr, ItemData *pItem, UINT uMaxHeight = 300)
{
if (g_plugin.bShowPreview) {
- int iWidth = 300;
+ int iHeight = uMaxHeight;
pItem->pOwner->webPage.load_image(wszUrl);
if (Bitmap *pImage = pItem->pOwner->webPage.find_image(wszUrl))
- if (pImage->GetWidth() < 300)
- iWidth = pImage->GetWidth();
+ if (pImage->GetHeight() < uMaxHeight)
+ iHeight = pImage->GetHeight();
- buf.AppendFormat(L"<img style=\"width: %d;\" src=\"%s\" title=\"%s\" alt=\"%s\"/><br>",
- iWidth, wszUrl.c_str(), wszDescr.c_str(), wszDescr.c_str());
+ buf.AppendFormat(L"<img style=\"height: %d;\" src=\"%s\" title=\"%s\" alt=\"%s\"/><br>",
+ iHeight, wszUrl.c_str(), wszDescr.c_str(), wszDescr.c_str());
}
else buf.AppendFormat(L"<a class=\"link\" href=\"%s\">%s</a>", wszUrl.c_str(), wszDescr.c_str());
}
@@ -132,13 +132,23 @@ static void AppendString(CMStringW &buf, const wchar_t *p, ItemData *pItem)
else if (!wcsncmp(p, L"img=", 4)) {
p += 4;
+ int iMaxHeight = 0;
+ const wchar_t * pHeightBegin = nullptr;
+ if (pHeightBegin = wcsstr(p, L" height=")) {
+ auto* p1 = pHeightBegin + 8;
+ if (auto* p2 = wcschr(p1, ']')) {
+ CMStringW wszHeight(p1, int(p2 - p1));
+ iMaxHeight = _wtoi(wszHeight);
+ }
+ }
+
if (auto *p1 = wcschr(p, ']')) {
- CMStringW wszUrl(p, int(p1 - p));
+ CMStringW wszUrl(p, int((pHeightBegin ? pHeightBegin : p1) - p));
p1++;
if (auto *p2 = wcsstr(p1, L"[/img]")) {
CMStringW wszDescr(p1, int(p2 - p1));
- AppendImage(buf, wszUrl, wszDescr, pItem);
+ AppendImage(buf, wszUrl, wszDescr, pItem, iMaxHeight ? iMaxHeight : 300);
p = p2 + 5;
}
}