#210 - Media file extension fix

This commit is contained in:
Elio Struyf
2021-12-26 11:52:45 +01:00
parent d667b19716
commit 24f79d9d3f
3 changed files with 15 additions and 5 deletions
+9
View File
@@ -1,5 +1,14 @@
# Change Log
## [5.9.0] - 2021-01-XX
### 🎨 Enhancements
### 🐞 Fixes
- [#210](https://github.com/estruyf/vscode-front-matter/issues/210): Fix for adding media files with uppercase file extensions
## [5.8.0] - 2021-12-21 - 🎄
### 🎨 Enhancements
+1 -1
View File
@@ -313,7 +313,7 @@ export class MediaHelpers {
private static filterMedia(files: Uri[]) {
return files.filter(file => {
const ext = extname(file.fsPath);
return ['.jpg', '.jpeg', '.png', '.gif', '.svg'].includes(ext);
return ['.jpg', '.jpeg', '.png', '.gif', '.svg'].includes(ext.toLowerCase());
}).map((file) => ({
fsPath: file.fsPath,
vsPath: Dashboard.getWebview()?.asWebviewUri(file).toString(),
+5 -4
View File
@@ -27,11 +27,12 @@ export class MediaLibrary {
workspace.onDidRenameFiles(e => {
e.files.forEach(f => {
const path = f.oldUri.path.toLowerCase();
// Check if file is an image
if (f.oldUri.path.endsWith('.jpeg') ||
f.oldUri.path.endsWith('.jpg') ||
f.oldUri.path.endsWith('.png') ||
f.oldUri.path.endsWith('.gif')) {
if (path.endsWith('.jpeg') ||
path.endsWith('.jpg') ||
path.endsWith('.png') ||
path.endsWith('.gif')) {
this.rename(f.oldUri.fsPath, f.newUri.fsPath);
MediaHelpers.resetMedia();
}