My code below is not working and i’m not sure why. I’ve tried a few variants. according to the KPR variables output, the image I’m trying to access is here.
$variables[‘field_about_image’][0]
i think the 0 signifies it is the first (and only in this case) image on the page w/ the machine field name ‘field_about_image’. so i wrote my code as:
function myTheme_preprocess_node(&$variables){ if($variables['type']=='basic_page_with_pic') { echo '<script>alert("my func running")</script>'; //Verified it's working $variables['field_about_image'][0]['class'] = 'myclass; } }
i’ve also tried this, just to get a class attribute added
$variables['field_about_image'][0][] = 'class';
also the title attribute comes up as empty. so just as an execrcise i tried this.
$variables['field_about_image'][0]['title'] = 'some title;
any help on how to do this would be greatly appreciated!
Sponsored by SupremePR