Skip to content

Commit

Permalink
Add support for xyz.amorgan.blurhash in ImageContent
Browse files Browse the repository at this point in the history
This adds an optional key to ImageContent, for displaying a blurhash on
the client before an image is loaded.
  • Loading branch information
redstrate committed Aug 19, 2023
1 parent 79257a0 commit 0ea5d48
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion Quotient/events/eventcontent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,10 @@ ImageInfo::ImageInfo(const QFileInfo& fi, QSize imageSize)

ImageInfo::ImageInfo(FileSourceInfo sourceInfo, qint64 fileSize,
const QMimeType& type, QSize imageSize,
const QString& originalFilename)
const QString& originalFilename, const QString &imageBlurhash)
: FileInfo(std::move(sourceInfo), fileSize, type, originalFilename)
, imageSize(imageSize)
, blurhash(imageBlurhash)
{}

ImageInfo::ImageInfo(FileSourceInfo sourceInfo, const QJsonObject& infoJson,
Expand All @@ -100,6 +101,8 @@ QJsonObject Quotient::EventContent::toInfoJson(const ImageInfo& info)
infoJson.insert(QStringLiteral("w"), info.imageSize.width());
if (info.imageSize.height() != -1)
infoJson.insert(QStringLiteral("h"), info.imageSize.height());
if (!info.blurhash.isEmpty())
infoJson.insert(QStringLiteral("xyz.amorgan.blurhash"), info.blurhash);
return infoJson;
}

Expand Down
4 changes: 3 additions & 1 deletion Quotient/events/eventcontent.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,13 @@ struct QUOTIENT_API ImageInfo : public FileInfo {
explicit ImageInfo(const QFileInfo& fi, QSize imageSize = {});
explicit ImageInfo(FileSourceInfo sourceInfo, qint64 fileSize = -1,
const QMimeType& type = {}, QSize imageSize = {},
const QString& originalFilename = {});
const QString& originalFilename = {},
const QString& imageBlurhash = {});
ImageInfo(FileSourceInfo sourceInfo, const QJsonObject& infoJson,
const QString& originalFilename = {});

QSize imageSize;
QString blurhash;
};

QUOTIENT_API QJsonObject toInfoJson(const ImageInfo& info);
Expand Down

0 comments on commit 0ea5d48

Please sign in to comment.