I have a "project" content type that I use for both website screen shots and videos. So when I create a view for recent projects I include the video field AND the image field - websites will have an image but no video and vice versa for video projects. I use a cloud zoom formatter on the imagefield and it works great for all my website projects, but when it comes to a video I have an empty field with "loading".
I checked "hide field when empty" and enables it on the view configuration, but the field still seems to be loading. It seems that when formatting the field you did not check to see if an image existed, I added one line that fixed my issue:
// Check if field has filepath
if($element['#item']['filepath'] != "") {
// Theme the preview image using imagecache
$small = theme('imagecache', $view_preset, $element['#item']['filepath']);
// Return the preview image as a link to the larger image with a cloud-zoom CSS class
return l($small, imagecache_create_path($zoom_preset, $element['#item']['filepath']), array('html' => TRUE, 'attributes' => array('class' => 'cloud-zoom');
}
I have no experience with writing patches and I am not even sure if this is the best solution. I really like this effect, I have even setup an admin for global configuration, but I haven't done all the options yet. When I have a chance to complete it I will share it.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 1x1t.gif | 44 bytes | elecomm |
| 28-07-2010 4-20-27 PM.jpg | 29.84 KB | michaelfillier |
Comments
Comment #1
grahamshepherd commentedI also experience this problem with 6.x-1.x-dev.
The standard cck display uses content-field.tpl.php which tests the variable $field_empty from content.module. $field_empty appears to be unavailable in cloud-zoom.module.
Like Michaelfillier, I have tested for empty in another way. I created a content-field-field_image.tpl.php in my theme and replaced
with
This works but I wonder if the hook_theme function is being correctly implemented.
Otherwise a fabulous module, thank you.
Comment #2
nicholasthompsonHmm... This is odd. Not other module needs to do this.
Comment #3
nicholasthompsonOn investigation, ImageCache seems to do this.
This only seems to occur if a field is set to be a single item. Multiple items do not invoke formatters if a value is empty. Very strange!
Fixed in 6.x-1.x-dev. Will port to D7 when I redo 7.x based on 6.x-1.x-dev.
Comment #5
Anonymous (not verified) commentedI had this bug, but the solutions above did not work in the .dev version.
When I did print_r($element['#item']) it displayed #delta =>0; I think that this means that it wasn't seeing it as empty.
I adjusted line
if (empty($element['#item'])) {to
if ( empty($element['#item']) OR empty($element['#item']['fid']) ) {I really do not know if this is the proper way that this should be done, but this removed the field from displaying. Anyone care to help ... or comment
Comment #6
elecomm commentedUsing Production version for Drupal 6. Got around this problem by defining default image as 1x1 transparent gif file. Hides the problem.
Comment #7
dakku commented