Hello,

I have noticed that when I leave a video field blank, the label and related DIVs are still shown while viewing the node.

Obviously this is problematic because I am trying to theme the video container and I don't want it displayed when there aren't any videos to show.

I did a few searches and couldn't find anything, if this has already been answered I apologize.

Thanks much

CommentFileSizeAuthor
#8 emthumb_empty_render.patch8.62 KBOnkelTem
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

llribas’s picture

I'm in the same problem....

i find this http://drupal.org/node/259265 but don't work for me...

Kirk’s picture

I ended up just doing a work-around at node.tpl.php

Essentially, I did this. Not sure if there is a better way to get the same outcome, but so far it seems to work exactly as I wanted. Took me a while to figure out to use ['value'], since my PHP knowledge is pretty recreational.

<?php if ($node->field_MYFIELD[0]['value'] != ''): ?>
 <div class="field-MYFIELD">
 <div class="field-label"><?php print $title ?> Videos</div>
 <div class="field-items">
 <?php
  foreach ($node->field_MYFIELD as $item) {
  print $item['view'];
  }
  ?>
 </div>
 </div>
<?php endif; ?>
OnlineWD™’s picture

Subscribing.

porg’s picture

Dear maintainer(s): This bug still exists in version 6.x-2.3. A response would be appreciated! Thanks!

How I realized it? I created a custom content type "Video" which has both a Video field and a 3rd Party Video field, so that it can use EITHER internal OR external video.

Possible video field scenarios and their effect on the HTML rendering are:

1) Internal undefined, external defined: External field rendered, internal field does not get rendered into HTML. Behavior as expected!

2) Internal defined, external undefined: Internal field rendered, unexpectedly the external field is rendered as well! Considering this as a bug! Why? Rendering an undefined (internal video) field makes no sense in terms of data structure and SEO, and in some cases it can also disturb the style/layout and therefore user experience/interface. In my case emfield's "orphaned" Lightbox play button is positioned so unhappily, that it overlays other elements of the page.

These are the modules, in the order of how I considered their responsibility:

1) CCK as it generally handles fields. From its issue tracker, I came to the conclusion, that it feels not really responsible to decide whether to render/omit empty fields, and rather leaves this decision to the processing later in the pipe (see: Empty field handling), to other modules which use fields, or even later, in the template.php logic (see: Do not output empty fields) .

2) FileField as it particularly allows file fields (such as the internal video files). According to Empty imagefield goes to HTML, this module correctly omits empty fields since 2009-03. From my experience with the Video field mentioned above, I can confirm that it correctly omits empty fields.

3) Embedded Media Field as it particularly provides the 3rd party media fields. A possible solution via template logic seems to be mentioned in Array exists even if no items added. Nevertheless a better handling by the module's logic would be desirable.

porg’s picture

Version: 5.x-1.3 » 6.x-2.3
Category: support » bug
porg’s picture

My intermediary solution: I keep the content type "Video" as is, so that it still has a Video field and a Emfield 3rd Party Video field, but defacto only use the Video field. At the Emfield I set the display fields for both teaser and node view to "exclude" and thereby enforce the omission. Into the help field I write "3rd party field shall currently not be defined until a technical problem is solved. If you want to publish video do so through the "Video" field".

As soon as Emfield's bug gets fixed, I will switch Emfield's display fields back on, and from then on I can create "Video" pages with either internal or external video content.

kobnim’s picture

In general, multi-valued emvideo fields have been working fine for me.
But today I am seeing a similar problem: an empty multi-valued emvideo field displays the video icon.

I exported the content type ("old") and re-imported it under a new name ("new").
And the problem went away!

I then exported the "old" and "new" content types and compared them. Here are the differences:

OLD:

    'providers' => 
    array (
      'custom_url' => true,
      'flickr' => true,
      'imageshack' => true,
      'photobucket' => true,
      'picasa' => true,
    ),

NEW:

    'providers' => 
    array (
      1 => 1,
      0 => 1,
      'custom_url' => false,
      'flickr' => false,
      'imageshack' => false,
      'photobucket' => false,
      'picasa' => false,
    ),

OLD:

'meta_fields' => 
    array (
      'title' => true,
      0 => 1,
      'description' => false,
    ),

NEW:

    'meta_fields' => 
    array (
      1 => 1,
      0 => 1,
      'title' => false,
      'description' => false,
    ),

OLD:

    'default_value_widget' => 
    array (
      'field_emvideo_mgal' => 
      array (
        0 => 
        array (
          'embed' => '',
          'value' => '',
          'emvideo' => 
          array (
            'title' => '',
          ),
        ),
      ),
    ),

NEW:

    'default_value_widget' => 
    array (
      'field_emvideo_mgal' => 
      array (
        0 => 
        array (
          'embed' => '',
          'value' => '',
        ),
      ),
    ),

Bottom line, you might try exporting and re-importing your content type.

OnkelTem’s picture

Version: 6.x-2.3 » 6.x-2.5
FileSize
8.62 KB

Created a patch for the issue.

When field formatter is set to its basic type - showing a thumb, no problems occures. As we see from emthumb.theme.inc:

  function theme_emthumb_imagecache_formatter_default($element) {
    return _emthumb_imagecache_formatter_default($element);
  }

and from _emthumb_imagecache_formatter_default() :

   if (!isset($options)) {
    $options = _emthumb_formatter_theme_helper($element);
  }
  if ($options['item']['value']) {
...
}

theming stops if $options['item']['value'] has its value. Strange, but none of the other theming functions - for lightbox2, for full video replacement etc - has no any checks:

function theme_emthumb_imagecache_formatter_lightbox2($element) {
  $options = _emthumb_formatter_theme_helper($element); 
  $options['thumbnail'] = _emthumb_imagecache_formatter_default($element); // why proceeding for no value??
  switch ($options['module']) {
    case 'emvideo':
      return theme('emvideo_lightbox2', $options['field'], $options['item'], $options['formatter'], $options['node'], $options);
  }
}

So I simply added checks everywhere like:

function theme_emthumb_imagecache_formatter_lightbox2($element) {
  $options = _emthumb_formatter_theme_helper($element); 
  if ($options['item']['value']) {
    $options['thumbnail'] = _emthumb_imagecache_formatter_default($element); // why proceeding for no value??
    switch ($options['module']) {
      case 'emvideo':
        return theme('emvideo_lightbox2', $options['field'], $options['item'], $options['formatter'], $options['node'], $options);
    }
  }
}
...
dale42’s picture

Experiencing the problem of incomplete output being produced when the field is empty. Does not happen when display is set to default in node display. It does happen:
- When Content Type > Display Fields is set to an thumbnail w/Lightbox2
- In Views when output is set to thumbnail w/Lightbox2

Drupal 6.22, Embedded Media Field 6.x-2.5, Media: Vimeo 6.x-1.1, Lightbox2 6.x-1.11

Patch in #8 resolves the issue.

porg’s picture

As #9 reports patch #8 as working: Could this please be merged into mainline?! Thanks.

inky@inky3d.com’s picture

The patch in #8 worked for me too.

Even though the video field was empty, its label and divs were appearing in the view.
The patch has sorted that out for me.

Michael-IDA’s picture

Base cause is (probably) a PHP version change.

Just moved a site from one host to another, updated core from 6.22 to 6.26 (for error 500s from higher version of PHP), no modules updated, get this problem.

# drush pmi emfield
Extension : emfield
Project : emfield
Type : module
Title : Embedded Media Field
Version : 6.x-1.26

# php -v
PHP 5.2.17 (cli) (built: Oct 30 2012 16:03:14)

Just an FYI post,
Sam

Michael-IDA’s picture

Version: 6.x-2.5 » 6.x-2.6
Status: Active » Reviewed & tested by the community

Against emfield 6.x-2.6

cd sites/all/modules/emfield
wget -c "http://drupal.org/files/issues/emthumb_empty_render.patch"
patch -p0 -i emthumb_empty_render.patch

Works to not have video fields display on node when empty.

Someone want to commit this?

Best,
Sam

aaron’s picture

Version: 6.x-2.6 » 6.x-2.x-dev
Issue summary: View changes
aaron’s picture

Status: Reviewed & tested by the community » Needs work

It doesn't apply to the current dev.