Great module! I concur with others that this is great for those non-programmers among us.

I am filtering two different node types in a table view. Each one of these node types has a thumbnail, I would like to set up in the View a field (or two) to show one thumbnail or the other. So if it is node type:A we only see thumbnail A or node type:b we only see thumbnail B.

Is this possible?

Comments

catch’s picture

Status: Active » Needs review

By thumbnail do you mean cck imagefield or something else?

catch’s picture

Status: Needs review » Postponed (maintainer needs more info)

oops.

michellepurestock’s picture

Hi,

I am using two modules to create video. One for flash upload video and one for embed media field gets the thumbnail from other video sharing sites. Each module has a different way of generating a thumbnail. Flash Upload Video generates a thumbnail from the module, embed media field gets it from the original external sites code.

The upload video comes with a placeholder thumbnail that shows until one has been converted during the conversion to flash process.

I can add both of these fields of the thumbnail to a view when using a table but when the table row is showing an embed media field it shows both the embed media field thumbnail and the placeholder thumbnail from flash upload video.

Interestingly this does not happen the other way around, if the table row is showing the flash upload video node type the thumbnail field only shows the one generated for flash upload video.

sun’s picture

Project: Views (for Drupal 7) » Embedded Media Field
Version: 5.x-1.6 » 5.x-1.x-dev

Sorry, this issue cannot be solved within Views.

BeaPower’s picture

Can this still be solved with any recent modules? I too am wondering how this can be done.

aaron’s picture

This is now possible with a combination of Styles and Node Reference / Embed Media Browser (nrembrowser). The Styles module creates Styles presets, which allow fields in CCK & Views to be displayed according to a class defined by a filter callback, allowing, for instance, the display to be dependent on node type or filefield mimetype. Nrembrowser implements some basic functionality for node references, filtering by node type. It also adds a nifty 'media'-like widget browser for editors to insert photos, videos, blog posts, etc. into content field or inline to WYSIWYG.

Note that Styles UI doesn't work yet, which means until it does that new styles (such as for video) need to be created programatically, by extending the NrembrowsersStyles class, which is a pita:

in includes/my_video.styles.inc:

class MyVideoStyle extends NrembrowserStyles {
  function video($effect) {
    $node = $this->set('node', node_load($this->get_nid()));
    $this->set_output(theme('emvideo_video_video', NULL, $node->field_video[0], NULL, $node, array('width' => $this->get_width(), 'height' => $this->get_height())));
  }
}

and then in my_video.module

function my_video_styles_default_containers_alter(&$containers) {
  $containers['nodereference']['containers']['video']['class'] = 'MyVideoStyles';
}

function my_video_styles_default_styles_alter(&$styles) {
  $styles['nodereference']['styles']['video'] = array(
    'label' => 'Video',
    'description' => 'Render the field as a video or a thumbnail.',
    'name' => 'video',
    'module' => 'my_video',
    'storage' => 4,
  );
}

/**
 * Implementation of hook_styles_default_presets_alter().
 */
function my_video_styles_default_presets_alter(&$presets) {
  $presets['nodereference']['containers']['video']['default preset'] = 'video';
  $presets['nodereference']['containers']['video']['styles']['video']['default preset'] = 'video';
  $presets['nodereference']['containers']['video']['presets']['video'] = array(
    'resize' => array(
      'width' => 240,
      'height' => 190,
    ),
    'video' => array(),
  );
}

/**
 * Implementation of Styles module hook_styles_register().
 */
function my_video_styles_register() {
  return array(
    'MyVideoStyles' => array(
      'field_types' => 'nodereference',
      'name' => t('MyVideoStyles'),
      'description' => t('This adds video support to nrembrowser.'),
      'path' => drupal_get_path('module', 'my_video') .'/includes',
      'file' => 'my_video.styles.inc',
    ),
  );
}

and technically all of it other than my_video_styles_register could live in /includes/my_video.styles.inc, and should be automatically called as needed by the Styles module.

I'll finish up the Styles UI soon enough, but for early adopters, this solution already works.

Hope this helps!

aaron’s picture

Note that after doing this, you'll see a new formatter when you display your node reference field, titled 'Nodereference style: Video'.

aaron’s picture

also, it precludes that your video content type is called 'video', with a 'field_video'. otherwise, all of the

$containers['nodereference']['containers']['video']['class']

and

$preset['nodereference']['containers']['video']['class']

references should be:

$containers['nodereference']['containers']['CCK_TYPE']['class']
$preset['nodereference']['containers']['CCK_TYPE']['class']

and

$node->field_video[0]

should be

$node->field_FIELD_TYPE[0]

Like I said, a pita right now...

aaron’s picture

Finally, to change the thumbnail width/height, you'll also need to alter or add the existing Thumbnail preset. I leave that as an exercise for the reader; you'll need to dig through the code.

aaron’s picture

Version: 5.x-1.x-dev » 6.x-1.24

And finally, I just noticed the version. This is for Drupal 6, unfortunately.

aaron’s picture

And I read the original post again, and saw my solution isn't exactly what was wanted; however, it could fairly easily be modified to do what's wanted, by using theme('emvideo_video_thumbnail') instead. Except you don't even need most of that, as emfield thumbnails are automatically generated with the module. But it might need handling for the Flash Upload Video module; I'm not familiar with that module.

aaron’s picture

to be honest, you can probably implement what you want with views simply by displaying both relevant fields; if the field doesn't exist in one type, it will be empty. however, be forewarned that (i believe) you will end up with an empty div, which might cause problems in css, depending on how you're using the wrappers.

alex ua’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

I'm marking this one as fixed given the comments in #11 & #12