-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: #7444 Re-factor handling of og:image tags #7463
Conversation
- Updated logic to set additional og:image tags based on more factors - logo.png fallback
// Returns array of this post's uploads | ||
db.getSortedSetRange('post:' + pid + ':uploads', 0, -1, callback); | ||
}; | ||
|
||
Posts.uploads.listWithSizes = async function (pid) { | ||
const paths = await Posts.async.uploads.list(pid); | ||
const sizes = await db.getObjects(paths.map(path => 'upload:' + md5(path))); | ||
const sizes = await db.async.getObjects(paths.map(path => 'upload:' + md5(path))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@barisusakli I experienced an issue here. If at top of file I require('../database').async
, then later on in the file, console.log(db);
was undefined
if called from inside Posts.upload.list
.
I ended up fixing it by doing db.async
when used inside the file instead.
Just to give you some context, the upgrade script I was writing was calling await Posts.uploads.list()
, and erroring out as db
was undefined
.
The new logic will supply
og:image
tags in the following order:og:image
if set in ACP, otherwise,brand:logo
if set in ACP, otherwise/logo.png
A provided upgrade script will calculate sizes for all uploads tracked in NodeBB (if they're associated with a post, that is), and will then insert the appropriate
og:image:height
andog:image:width
tags.