I wanted to try to use the file's description instead of the file name for the actual link text. So I created a custom phptemplate_filefield() in my template.php file and proceeded to replace check_plain($name) with check_plain($desc). It appears as though the line

$desc = $file['description'];

does not actually reference the description. I noticed the descriptions are kept in the node_content_XXX tables themselves, so I wrote a couple of lines inside my custom phptemplate_filefield() function to query for the correct descriptions. This isn't very efficient, as a custom if statement must be used for each separate file instance. Any help or suggestions would be appreciated.


I solved this in a proper way with my revisions support patch, along with using {file_revisions} for the 'description' value. The key to the solution is to pass the given $item, not a newly loaded $file, in filefield_field_formatter(). $item already contains all the required data, description included.

Let's remember to close this bug once the revision patch has been applied.

Status:Active» Needs review
new1.23 KB

This patch should do it. I can't test it currently because my database scheme is different than HEAD's, but I'm pretty confident that it works. Please test and review.

Version:4.7.x-1.x-dev» 6.x-3.x-dev

Update the status, my patch is for filefield HEAD.

Category:support» feature

On further thought, this should be a feature request instead of a support request.

I tried the patch and it seems to work when viewing the content node. However now it looks as though the file links are not showing up when including a filefield inside a view. I'll look around a bit more to see if I can find the problem. Thank you for the patch.

Status:Needs review» Fixed

Thanks for the hint, I can see now why my patch didn't work. I committed an improved version to filefield HEAD, both description texts and Views listings work now.

Perfect, works like a charm. Thank you.

Status:Fixed» Closed (fixed)

Version:6.x-3.x-dev» 6.x-3.0-alpha7
Status:Closed (fixed)» Active

Does this patch work for 6.x-3.0-alpha7?


You don't need to apply the patch because it is included in the current version (alpha7).

Status:Active» Fixed

I have Alpha7 installed, but i can't figure out how to use the Description instead of the filename as the link text!
Please someone shed some light on it :)

Hmm, you're right. For some reason the "description" is only used as the link "title" attribute, not the text of the link. I'm marking this active since I think it should be the default output. If the description is present, then it should be the text and the filename should be the "title" attribute.

<a href="{file-url}" title="{file.png}">{description}</a>

new2.6 KB

Oh, well I meant to set this issue back to active. Regardless, this is now fixed because I've committed the attached patch which makes the description the link text by default.

Hi folks,

I don't know if I'm the first to encounter this bug, but when I updated my FileField module to v6.x-3.0-beta3, I noticed that the hyperlinks to my uploaded files were all being displayed as "a".

The issue seems to be that properties of files are being serialized before saving in the database in table 'content_field_FIELDFIELD_ID'.

There should be a unserialisation before using these values, and after skimming through the code I noticed there wasn't, so the first lettre of the serialised string was being used, namely 'a' from 'a:1{}'.

The fix is easy:

Open up filefield_formatter.inc, go to line 16 where you see the following function:

function theme_filefield_formatter_default($element) {
  $file = $element['#item'];
  $field = content_fields($element['#field_name']);
  $output = theme('filefield_item', $file, $field);
  return $output;

Change this to:

function theme_filefield_formatter_default($element) {
  $file = $element['#item'];
  //  Unserialize file data if not yet unserialised
  if ( !is_array($file['data']) )
$file['data'] = unserialize($file['data']);
  $field = content_fields($element['#field_name']);
  $output = theme('filefield_item', $file, $field);
  return $output;

Sometimes the filedata array is already unserialised, but when called from a view, it seemed not unserialised, and thus I had to fix the code.

That should do it :)


nightlife2008 this has already been fixed, see #299329: No display of alt or title with images - Simple Workaround.

Status:Fixed» Closed (fixed)

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