How do I alter the rendering of a field in a View?
Where can I access the render array before the html is generated for output?
For example, if I have an image field included in my view, where can I add to the attributes of the image before the image is rendered using theme_image
? Assuming that the field is eventually still rendered using theme_image
.
I want to add attributes to the image tag and NOT the surrounding divs
that Views inserts into the markup.
EDIT based on answer by Jimajamma:
Editing the $view->result
as suggested is causing the View to crash. Page doesn't render correctly anymore:
function MYMODULE_views_pre_render(&$view) {
if ($view->name=='viewyouarelookingfor') {
foreach($view->result as $row) {
$row['field_body'][0]['rendered']['#markupe'] = '<p>Test!</p>'; // causes View to crash
}
}
}