diff --git a/retroshare-gui/src/gui/chat/ChatWidget.cpp b/retroshare-gui/src/gui/chat/ChatWidget.cpp index abab8336a..463b73612 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.cpp +++ b/retroshare-gui/src/gui/chat/ChatWidget.cpp @@ -1737,9 +1737,11 @@ void ChatWidget::fileHashingFinished(QList hashedFiles) if (!image.isEmpty()) { message += QString("").arg(image); } + message += link.toHtmlSize(); + } else { + message += "
" + link.toHtmlSize(); } } - message += link.toHtmlSize(); if (it != hashedFiles.end()) { message += "
"; diff --git a/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp b/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp index 4236b6f04..e2b0e175b 100644 --- a/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp +++ b/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp @@ -560,11 +560,39 @@ void CreateGxsForumMsg::fileHashingFinished(QList hashedFiles) QList::iterator it; for (it = hashedFiles.begin(); it != hashedFiles.end(); ++it) { HashedFile& hashedFile = *it; + QString ext = QFileInfo(hashedFile.filename).suffix().toUpper(); + RetroShareLink link = RetroShareLink::createFile(hashedFile.filename, hashedFile.size, QString::fromStdString(hashedFile.hash.toStdString())); - if (link.valid()) { - mesgString += link.toHtmlSize() + "
"; + + bool preview = false; + if(hashedFiles.size()==1 && (ext == "JPG" || ext == "PNG" || ext == "JPEG" || ext == "GIF" || ext == "WEBP")) + { + QString encodedImage; + uint32_t maxImageSize = 32000; + if (link.valid()){ + if (RsHtml::makeEmbeddedImage(hashedFile.filepath, encodedImage, 320*240, maxImageSize - 200 - link.toHtmlSize().length())) + { QTextDocumentFragment fragment = QTextDocumentFragment::fromHtml(encodedImage); + ui.forumMessage->textCursor().insertFragment(fragment); + preview=true; + } + } } + if(!preview) + { + QString image = FilesDefs::getImageFromFilename(hashedFile.filename, false); + if (!image.isEmpty()) { + mesgString += QString("").arg(image); + } + if (link.valid()) { + mesgString += link.toHtmlSize() + "
"; + } + } else { + if (link.valid()) { + mesgString += "
" + link.toHtmlSize() + "
"; + } + } + } if (!mesgString.isEmpty()) {