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.

CommentFileSizeAuthor
#6 1x1t.gif44 byteselecomm
28-07-2010 4-20-27 PM.jpg29.84 KBmichaelfillier

Comments

grahamshepherd’s picture

Version: 6.x-1.0 » 6.x-1.x-dev

I 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

<?php 
if (!$field_empty) : 
?>

with

<?php 
$item = $items[0];
$fid = $item['fid'];
if (!empty($fid)) :  
?>

This works but I wonder if the hook_theme function is being correctly implemented.
Otherwise a fabulous module, thank you.

nicholasthompson’s picture

Hmm... This is odd. Not other module needs to do this.

nicholasthompson’s picture

Status: Active » Fixed

On 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.

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Status: Closed (fixed) » Needs review

I 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

elecomm’s picture

Version: 6.x-1.x-dev » 6.x-1.0
Priority: Normal » Minor
Status: Needs review » Needs work
StatusFileSize
new44 bytes

Using Production version for Drupal 6. Got around this problem by defining default image as 1x1 transparent gif file. Hides the problem.

dakku’s picture

Status: Needs work » Closed (outdated)