how to filter extensions | Community
Skip to main content
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by edubey

Simple approach would be to use regex. Please use this code and keep all extension you want or add or remove

regex :/\.(png|jpg|jpeg)$/, regexText : "Please choose an correct file"

5 replies

smacdonald2008
Level 10
November 25, 2015

See the reference doc

ttps://docs.adobe.com/content/docs/en/cq/5-6-1/widgets-api/?class=CQ.form.PathField

Level 4
November 25, 2015

Yes but i cannot find the property

I have tried with linkPattern but doesn't work

smacdonald2008
Level 10
November 25, 2015

ANother way to perform this use case is to write a custom predicate. See this community article:

http://wemcode.wemblog.com/custom-predicate-for-pathfield

edubey
edubeyAccepted solution
Level 10
November 25, 2015

Simple approach would be to use regex. Please use this code and keep all extension you want or add or remove

regex :/\.(png|jpg|jpeg)$/, regexText : "Please choose an correct file"
kautuk_sahni
Community Manager
Community Manager
November 26, 2015

Hi 

Please go through the documentation of "CQ.form.PathField",

Link:- https://docs.adobe.com/docs/en/cq/5-6/widgets-api/index.html?class=CQ.form.PathField

You can use :

regex :

linkPattern : String

A pattern to format links after selection in the browse dialog (using CQ.Util.patchText). This is used when only a tr...

parLinkPattern : String

A pattern to format links after selection of a paragraph in the browse dialog (using CQ.Util.patchText). This only ap...

 

As mentioned by Scott, you would need to write custom pathfield, 

Pathfield has a property called predicate which can be used for filtering. You can create and register a custom predicate that returns false for the paths you don't want to be visible in the the dialog. The name of the custom predicate can then be passed to the config of pathfield.

You can find information here : http://wemcode.wemblog.com/custom-predicate-for-pathfield

For more on predicates, the following links can be referred :

http://www.wemblog.com/2013/04/how-to-create-custom-query-predicate-in.html

http://labs.sixdimensions.com/blog/2013-07-10/custom-predicateevaluators-or-how-i-learned-stop-worrying-and-love/

 

I hope this would help you.

Thanks and Regards

Kautuk Sahni

Kautuk Sahni