I have a use for the ability to create a view where the size of a file is a field in the view. This would ideally have two formatters. One would be the actual size in bytes (e.g. 1234322) and the other would be a human readable size (e.g. 1.8 MB).

Comments

quicksketch’s picture

Basically the same as #424642: Format "File: Mimetype" Field. FileField does not own the "files" database table, so it's not really the correct module to adjust the output of that database column.

will_in_wi’s picture

I assumed that these were two different, though related, feature requests and should be filed as such. If this is not the case, I will make this a dup.

quicksketch’s picture

Title: Expose file size as field in views » Format File: Filesize Field
Project: FileField » Views (for Drupal 7)
Version: 6.x-3.x-dev » 6.x-2.x-dev
Status: Active » Needs review
StatusFileSize
new1.23 KB

No I think splitting them up is fine. Here's a patch to Views module to make this a selectable option.

merlinofchaos’s picture

Status: Needs review » Needs work

This patch has a form for an option but does not define the option via options_definition -- this is required.

quicksketch’s picture

Doh, sorry. Just a quick stab at the request. will_in_wi, perhaps you can try to finish it up?

will_in_wi’s picture

Perhaps instead of all of this work, I can find a better way to do what I am trying to do. The reason I created these feature requests was that I have a organic groups site. I am trying to allow each group to have a place that they can dump documents. I want to be able to see a list from which you can see the name of the document, a description of the document, the type of document, the size of the document, etc... I also want to be able to make a document private to that group on a single document level. I created a node type with a filefield and was trying to use views to create the list. Is there a better way?

Also, I am not sure if we are confusing the views file listing, or a views node listing with a filefield cck field. I have the latter, and I am trying to show the metadata from a file in that filefield. This is why I thought these feature requests went under the filefield module rather than views. I have tried to create modules for cck2 and views2 in the past and have totally failed due to a lack of documentation, and a lack of time to search through code to figure it out.

dawehner’s picture

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

i added the options definition

here is a patch, out of views root

quicksketch’s picture

will_in_wi, now you've diverted from your original issue. ;-)

Please open a new support request for your question.

SamRose’s picture

Applied this patch manually to Views 6.x-2.3 but the format is not showing up. Where should we find this format (I am looking for it in "Content: File field" )?

quicksketch’s picture

SamRose, you have to make a relationship to the Files table by adding a Content: File field relationship, then adding a File: Filesize field.

SamRose’s picture

Works! Although, I do get a strange error that seems to be referring to javascript error:


Type	locale
Date	Wednesday, May 27, 2009 - 2:19pm
User	 Sam Rose
Location	admin/reports/dblog
Referrer	admin/build/views/edit/my_view
Message	Parsed JavaScript file misc/tableheader.js.
Severity	notice
Hostname	localhost
Operations	

But, that may not have anything to do with patch above. other than that, it worked

merlinofchaos’s picture

Status: Needs review » Fixed

That error doesn't seem to have anything to do with the patch, I don't think. Committed.

Status: Fixed » Closed (fixed)

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