Is there any way to expose a filefield's file extension to views? Using a relationship for the field's FID allows access to lots of metadata, but the file extension doesn't seem to be an option.

Comments

quicksketch’s picture

Title: Expose file extension to views? » Add file extension as a field available within the File group
Project: FileField » Views (for Drupal 7)
Component: User interface » files/upload data

Because this is a property available from the "files" database table which is provided by core, support for this would likely come from Views module itself because it provides integration with all supported core database tables.

dawehner’s picture

Status: Active » Needs review
StatusFileSize
new1.53 KB

Here is a patch. Later people could add a filter/argument

quicksketch’s picture

I dare say this should be called "extension" (i.e. "png" or "gif") instead of "file type" since that usually indicates mime type (i.e. "image/png" or "image/gif").

dawehner’s picture

Status: Needs review » Needs work

It sounds better, that's true.

quicksketch’s picture

And one minor details, this should just be // $Id$

+// $Id: $

The added space would probably prevent CVS from filling it in properly upon commit.

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new1.57 KB

aaah i wondered why i had changed this snippet but i think this was just totally wrong.
Thanks for the review and this code style update.

blup’s picture

+1 for this patch

bojanz’s picture

+    'help' => t('The file extension of the file.'),

A bit redundant? "The extension of the file." would match the other help texts.
"File: File extension" could then also be "File: Extension".
But this is all nitpicking...

Other than that, the patch applies cleanly and works nicely.

dawehner’s picture

StatusFileSize
new1.57 KB

Update

'help' => t('The extension of the file.'),
dawehner’s picture

StatusFileSize
new1.56 KB

Yet another rerole

bojanz’s picture

Status: Needs review » Reviewed & tested by the community

Awesome.

merlinofchaos’s picture

Version: 6.x-3.x-dev » 7.x-3.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Committed to 6.x-3.x -- needs porting to D7.

aspilicious’s picture

Tried to port this, but couldn't figure out the new structure.
file_managed vs file_uasge and stuff...

At least I tried

dawehner’s picture

Status: Patch (to be ported) » Fixed

@aspilicious
Ping me on irc whenever you have some problems with porting patches

Ported and fixed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Troy’s picture

I am having this problem. I want my users to be able to see the filename extension, but it isn't showing up. I read through this post hoping to find an answer, yet I am still coming up short. Anyone else had this problem with their extensions?