Remove icon and filename
mbiddlecombe - December 9, 2008 - 15:31
| Project: | jQuery Media |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
I have got videos showing up so that's a good start! But the video file icon and title still show.
I can remove the fileicon through css. Is there anyway of getting rid of the filename below the video?

#1
> I can remove the fileicon through css. Is there anyway of getting rid of the filename below the video?
I'm also interested in this.
At the moment my links in the content are in the form:
<a href='/path/to/file.swf>[use this as descriptive label]</a>which is totally acceptable, especially since the label wraps to the width of the video width.
But it would also be nice to be able to hide it too.
If I find a solution I'll post back.
#2
There is a workaround posted here - http://drupal.org/node/300853#comment-1111733 but not explained.
Here are the steps - this requires thinkering your template.php file. I don't know much JS nor PHP so if someone can show more elegant solution please feel free to post it.
1. Open your theme's template.php file. Find "function yourthemename_preprocess_node(&$vars, $hook)".
If there is no such function let's make one. Here's mine for example:
<?php
function zen_preprocess_node(&$vars, $hook) {
...
//lots of code here
...
if ($vars['page'] && $vars['type'] == 'video') { // Mind the node type. Mine is 'video'
drupal_add_js( 'jQuery(function($) {$(\'.filefield-file .filefield-icon\').hide(); $(\'.filefield-file div div\').hide();});', 'inline', 'header');
}
}
?>
#3
Thank you, Miteto - that solved my issues :)
#4
Great thanks, Miteto!
#5
for drupal 5x
<?php
drupal_add_js( '$(document).ready(function(){
$(".filefield-icon").hide();
$(".filefield-item > div div").hide();
});', 'inline');
?>
#6
Here is the other solution, IMHO it is kind of raw but I still find it better than above JS. This is because any ajax/ahah callbacks, for instance if you load your file in ajax_content thickbox above js from template.php won't work but you would need to put same js in thickbox.js file which is not very good practice.
<?phpfunction phptemplate_filefield_file($file) {
$path = $file['filepath'];
$url = file_create_url($path);
$icon = theme('filefield_icon', $file);
$options = array('attributes' => array('type' => $file['filemime'], 'length' => $file['filesize']));
$options['attributes']['title'] = (isset($file['data']['description'])) ? $file['data']['description'] : $file['filename'];
if ((arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == 'edit') || (arg(0) == 'filefield' && arg(1) =='ahah')) {
return '<div class="filefield-file clear-block">'. $icon . l($file['filename'], $url, $options) .'</div>';
}else{
return '<div class="filefield-file clear-block">'. l('', $url, $options) .'</div>';
}
}
?>
This override removes icon and file name only from display, not on node editing pages.
#7
That did the trick perfectly! Thanks nk_
#8
Hi,
I tried using contemplate without success. (#6)
I get a blank page and this code hides everything.
can this code (#6) be used with contemplate?
thanks
bredi
#9
where does snippet go?... and is it for 5.x or 6.x?
I'm on Drup5.7, FileField 2.4 & jQuery Media 1.3 - tried in template.php - didn't work
Thanks in advance for response
#10
@bredi: this file goes to your
template.phpfile. if you already don't have one create it in your theme directory. don't forget to clear your theme registry, best clearing your cache.@rhimes: this snippet is for D6, sorry if I forgot to mention. Looking at the fileField 2.4 version quickly I found that following might be solution for you.
I don't have D5 version handy ... Let me know if that works.
<?php
function phptemplate_filefield($file) {
if (user_access('view filefield uploads') && is_file($file['filepath']) && $file['list']) {
$path = ($file['fid'] == 'upload') ? file_create_filename($file['filename'], file_create_path($field['widget']['file_path'])) : $file['filepath'];
$icon = theme('filefield_icon', $file);
$url = file_create_url($path);
$desc = $file['description'];
if (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == 'edit')) {
return '<div class="filefield-item">'. $icon . l($desc, $url) .'</div>';
}else{
return '<div class="filefield-item">'. l('', $url) .'</div>';
}
}
return '';
}
?>
cheers, Nenad
#11
@ nk_ - dunno - did this instead - D5 (and I thought this was a D5 ver issue) FF2.4, jQM1.3:
in filefield.module @ ln#799 under function theme_filefield..... changed this:
return '<div class="filefield-item">'. $icon . l($desc, $url) .'</div>';to this:
// CHANGES*** below to hide icon & file description:return '<div class="filefield-item">'. l('', $url, $options) .'</div>';
works great
#12
rhimes,
one of the best things concerning drupal is theme overrides. Means it is not necessary to edit core files, it's even bad practice for many reasons,
maybe first of all each time you update this module you will need to go in the core and re-edit it again ...
Function I posted will do exactly the same for you and is safer, it is override on the theme level and if you put this function in your
template.phpit will precede (override) function in module. Besides, your hack will hide filename and icon on node editing form as well, not only in display,
which is not good idea as it's usable for editor to see it ...
Have a look on drupal documentation and book pages about theme overrides.
Best, Nenad
#13
is there a way to conditionally NOT remove the image icon?
#14
nk_, thanks for the fix.