'header_image')); $nb_nodes = count($nodes)-1; if($id===null){ // Selects a random node $nb = mt_rand(0,$nb_nodes); } else{ // Selects a random node that isnt the same as $id $nb = $id; while($id===$nb){ $nb = mt_rand(0,$nb_nodes); } } return $nb; } // Function that renders the image with it's link to an article function header_image_render_node($id,$classes=null){ $nodes_array = node_load_multiple(array(), array('type' => 'header_image')); $nodes = array_values($nodes_array); $node = $nodes[$id]; // Creates the links needed for the chosen node $image_url = file_create_url($node->field_image_link['und'][0]['uri']); $style = 'medium'; $medium_image_url = image_style_url($style, $image_url); if(file_exists($medium_image_url)){ $image_url = $medium_image_url; } $style = 'thumbnail'; $thumb_image_url = image_style_url($style, $image_url); if(file_exists($thumb_image_url)){ $image_url = $thumb_image_url; } $article_url = $node->field_article_url['und'][0]['value']; // Checks if the url has http before it so it doesn't link to an internal page $parsed = parse_url($article_url); if(empty($parsed['scheme'])) { $article_url = 'http://' . ltrim($article_url, '/'); } // Gets submitted classes if($classes!=null){ $result = "
"; } else{ $result = "
"; } $title = $node->title; // Creates the html to display $result .= "
"; echo $result; }