#595: Fix media metadata

This commit is contained in:
Elio Struyf
2023-06-29 17:13:32 +02:00
parent c1410de12e
commit e6b28ce7ba
2 changed files with 18 additions and 15 deletions
+1
View File
@@ -28,6 +28,7 @@
- [#572](https://github.com/estruyf/vscode-front-matter/issues/572): Fix the media snippet placeholder link
- [#577](https://github.com/estruyf/vscode-front-matter/issues/577): Fix in the `dataFile` field where data entries get overwritten
- [#590](https://github.com/estruyf/vscode-front-matter/issues/590): Fix for image fields inside a sub-block
- [#595](https://github.com/estruyf/vscode-front-matter/issues/595): Fix for media metadata now showing up
## [8.4.0] - 2023-04-03 - [Release notes](https://beta.frontmatter.codes/updates/v8.4.0)
+17 -15
View File
@@ -147,22 +147,24 @@ export class MediaHelpers {
const total = files.length;
// Get media set
files = files.map((file) => {
try {
const metadata = MediaLibrary.getInstance().get(file.fsPath);
const mimeType = lookup(file.fsPath);
files = await Promise.all(
files.map(async (file) => {
try {
const metadata = await MediaLibrary.getInstance().get(file.fsPath);
const mimeType = lookup(file.fsPath);
return {
...file,
dimensions:
mimeType && mimeType.startsWith('image/') ? imageSize(file.fsPath) : undefined,
mimeType: lookup(file.fsPath) || '',
...metadata
};
} catch (e) {
return { ...file };
}
});
return {
...file,
dimensions:
mimeType && mimeType.startsWith('image/') ? imageSize(file.fsPath) : undefined,
mimeType: lookup(file.fsPath) || '',
...metadata
};
} catch (e) {
return { ...file };
}
})
);
files = files.filter((f) => f.mtime !== undefined);
// Sort the files