The views module provides a views field for file extension (.jpg, .pdf, etc) but not a filter. Could we please have a filter so that we can build views showing only PDFs, for example?
The file type flter (provided by file entity module) is not sufficient because if file entity module is added to a site after there are already files in the system, there is no type defined for any of the files that predate the file entity module.
An alternative might be to provide a batch operation in file_entity() that would update the data for all the older files. See #1977662: On fresh install, existing files are assigned to 'undefined' file type
Comment | File | Size | Author |
---|---|---|---|
#6 | views-add_extension_filter.patch | 2.95 KB | omnia.ibrahim |
#4 | views-add_extension_filter-2015437-4.patch | 2.95 KB | imperator_99 |
#2 | views-add_extension_filter-2015437-1.patch | 2.95 KB | jenlampton |
Comments
Comment #1
jenlamptonLooks like that extension data comes from Views module :)
Comment #2
jenlamptonI couldn't figure out a way to add an expression to the field in the view, so I ended up going with the "ends with" filter that string comparison uses. it works, but it's not quite what I'd intended.
Comment #2.0
jenlamptonadd see
Comment #3
jenlamptonLooks like this is provided by the latest version of file entity. Closing.
Comment #4
imperator_99 CreditAttribution: imperator_99 commentedI couldn't figure out where File Entity was providing this, so I used the patch. Unfortunately it didn't work straight out, I was getting an error regarding the SQL query in line 18 of views_handler_filter_file_extension.inc. Turns out I had to change the 'origname' column in the SELECT statement to 'filename', which is what is used in the file_managed table.
Updated patch attached, for those who need it (entirely not sure if this is the correct way to do this, since I am patching a patch).
Comment #5
varshith CreditAttribution: varshith as a volunteer and commentedThis is indeed provided by the "file_entity" module.
After enabling the file_entity module, create a relationshiop in your view called (YOUR_FIELD:fid) and then you can use filter "File: Mime Type" (you can use contains operator there)
You can also create a view of "Files" and use them without relationships.
Comment #6
omnia.ibrahim CreditAttribution: omnia.ibrahim commentedPatch for views version views-7.x-3.20
Comment #7
rtnilesh.gupta CreditAttribution: rtnilesh.gupta commenteddouble file extension it is taking any idea how to stop? like salt.php.pdf not to take in drupal 7 webform but it is taking how to alter? por stop or is there any option to rename the extension. before upload or after upload. i need custom module or is there any module?