Skip to content
Snippets Groups Projects
Commit fef0cc2d authored by Nicolas Werner's avatar Nicolas Werner
Browse files

Fix some images not showing up

parent c2f2e832
No related branches found
No related tags found
No related merge requests found
...@@ -17,13 +17,16 @@ MxcImageResponse::run() ...@@ -17,13 +17,16 @@ MxcImageResponse::run()
auto data = cache::image(fileName); auto data = cache::image(fileName);
if (!data.isNull()) { if (!data.isNull()) {
m_image = utils::readImage(&data); m_image = utils::readImage(&data);
m_image = m_image.scaled(
m_requestedSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
m_image.setText("mxc url", "mxc://" + m_id);
if (!m_image.isNull()) { if (!m_image.isNull()) {
emit finished(); m_image = m_image.scaled(
return; m_requestedSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
m_image.setText("mxc url", "mxc://" + m_id);
if (!m_image.isNull()) {
emit finished();
return;
}
} }
} }
...@@ -34,7 +37,7 @@ MxcImageResponse::run() ...@@ -34,7 +37,7 @@ MxcImageResponse::run()
opts.method = "crop"; opts.method = "crop";
http::client()->get_thumbnail( http::client()->get_thumbnail(
opts, [this, fileName](const std::string &res, mtx::http::RequestErr err) { opts, [this, fileName](const std::string &res, mtx::http::RequestErr err) {
if (err) { if (err || res.empty()) {
nhlog::net()->error("Failed to download image {}", nhlog::net()->error("Failed to download image {}",
m_id.toStdString()); m_id.toStdString());
m_error = "Failed download"; m_error = "Failed download";
...@@ -46,6 +49,10 @@ MxcImageResponse::run() ...@@ -46,6 +49,10 @@ MxcImageResponse::run()
auto data = QByteArray(res.data(), res.size()); auto data = QByteArray(res.data(), res.size());
cache::saveImage(fileName, data); cache::saveImage(fileName, data);
m_image = utils::readImage(&data); m_image = utils::readImage(&data);
if (!m_image.isNull()) {
m_image = m_image.scaled(
m_requestedSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
}
m_image.setText("mxc url", "mxc://" + m_id); m_image.setText("mxc url", "mxc://" + m_id);
emit finished(); emit finished();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment