I've read through many questions asking this same thing, but I feel like I'm doing what they are suggesting and it's still not working.
I've created a custom module and enabled it. This is my code:
function mymodule_node_view($node, $view_mode, $langcode) {
if ($view_mode == 'teaser' && $node->type == 'article' && count($node->field_video) > 0) {
kpr($node);
$markup = sprintf("<video style='width: 502px; height: 282px;' poster='%s'>\n",
image_style_url('video_thumbnail', $node->field_video[$node->language][0]['thumbnailfile']->uri)
);
foreach($node->field_video[$node->language][0]['playablefiles'] as $video_object) {
$markup .= sprintf("<source src='%s' type='%s' />\n",
file_create_url($video_object->uri),
$video_object->filemime
);
}
$markup .= "</video>";
$node->content['field_video_embed_code'] = array(
'#markup' => $markup,
'#weight' => 10,
'#type' => 'markup',
);
kpr($node);
}
}
When I look at the krumo output, I see my changes to the $node object, however, when it renders the new field I'm adding is not included.
What am I doing wrong?
EDIT: I just realized I'm using Display Suite (it's been awhile since I set this site up) which is overriding which fields are shown and in what order. My guess is that DS is getting my modified content, but not showing the additional field because it isn't listed in my teaser fields? I'm not sure.