Hi,
I am using emfield video_cck and Views.
When I using video_cck in views it show the thumbnail with the link to the node, but in image ALT and TITLE properties it shows "See Video" text in all thumbnails.
Instead "See Video" text I want to show the node title in each thumbnail.
I don't have experience with php. In video_cck.module there is code:

$output = l('<img src="' . $thumbnail_url . '" width="' . $width  . '" height="' . $height  . '" alt="' . t('See Video') . '" title="' . t('See Video') . '" />', 'node/' . $node->nid, array(), NULL, NULL, false, true);

I have changed the code to:

$output = l('<img src="' . $thumbnail_url . '" width="' . $width  . '" height="' . $height  . '" alt="' . variable_get($node->title,'Preview image') . '" title="' . variable_get($node->title,'Preview image') . '" />', 'node/' . $node->nid, array(), NULL, NULL, false, true);

Now i see "Preview image" in all thumbnails and not the node title.

What I do wrong and how can I solve the problem? Please help.

Comments

OpenChimp’s picture

I'm trying to do the same thing.

I know that I could easily theme the field or the view to change this, but I was thinking that if it's possible, it would be better to create a patch for em-field so that it automatically uses the title of the video as the title text on thumbnail images and links. This would be better for usability and for SEO.

Sorry that I'm not able to provide a patch since I haven't figured out CVS yet, but here's the code I changed:

I created an override function in my template.php - phptemplate_video_cck_video_thumbnail and duplicated the code found in video_cck.module line#332 and then changed the code as follows (commented part is how it is in the module)

//      $output = l('<img src="' . $thumbnail_url . '" width="' . $width  . '" height="' . $height  . '" alt="' . t('See Video') . '" title="' . t('See Video') . '" />', 'node/' . $node->nid, array(), NULL, NULL, false, true);
      $output = l('<img src="' . $thumbnail_url . '" width="' . $width  . '" height="' . $height  . '" alt="' . $node->title . '" title="' . $node->title . '" />', 'node/' . $node->nid, array(), NULL, NULL, false, true);

This is basically the same thing dima700 was trying but without the variable_get. The fact that dima was getting "Preview image" returned confirms my suspicion that the $node->title variable isn't available for use here. This is kind of surprising to me. I thought that all the basic node variables would accessible from here. I know that uid and nid work, but many of the others return "".

Is there another approach to doing this?

I'm probably going to have to solve it through the theming of the view or the field at this point because of time constraints but I think this would be a good patch it it's possible to do.

OpenChimp’s picture

Category: support » feature
aaron’s picture

Project: Video CCK » Embedded Media Field
Component: Code » Embedded Video Field
Assigned: Unassigned » aaron

yep, this needs to happen. moving to the correct issue queue.

George2’s picture

you need to do a $node = node_load($node->nid); before using node->title MikeyLikesIt

aaron’s picture

Priority: Normal » Critical

bumping up priority to make sure it happens soon. thanks

dima700’s picture

George2,
This exactly what I did to solve the problem.

OpenChimp’s picture

adding the $node = node_load($node->nid); before printing $node->title worked. The thumbnails now contain the correct title text in the alt and title attributes.

I'm a little worried about how much overhead this is causing. It's probably not a big deal, since my views display no more than a dozen or so thumbnails per page, but it still doesn't seem right to do a full node_load() just to get the title of the node.

Anyway, thanks for the help...