Reputation: 5683
Trying to author a vscode extension to resize an image file. I want to right click an image file type in the explorer to trigger the extension.
I've got the selected item file path from explorer view by passing a vscode.URI
parameter to the command from the initial context. But I have a question regarding how to filter the menu to only appear on images:
How can I only show the menu context item when the file is an image type? Is there way to specify something like this in the extension context?
{
"when": "resourceFilename == CA375AS062_princeton_3750_angle_shader_paint_brush_size_5_8__1000.jpg",
"title": "Resize Image",
"command": "fireshop.resizeImage",
"group": "fireshop-nav"
}
This condition works so left side is right, but I want to detect just the file suffix as .jpg, .jpeg, .png
etc. Is it possible? (the docs on the when conditions needs some improvement!)
Upvotes: 4
Views: 544
Reputation: 869
The solution is to use resourceExtname
to "filter" on extension name.
{
"command": "fireshop.resizeImage",
"group": "navigation",
"when": "resourceExtname == .jpg"
}
It was implemented in Oct, 10th with PR 34889
Upvotes: 2