Skip to content

Instantly share code, notes, and snippets.

@zerolab
Created August 1, 2010 12:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zerolab/503290 to your computer and use it in GitHub Desktop.
Save zerolab/503290 to your computer and use it in GitHub Desktop.
Custom Drupal menu items images
<?php
/**
* Implements theme_menu_item_link()
* Courtesy of http://chrisshattuck.com/blog/how-use-images-menu-items-drupal-simple-preprocessing-function
*/
function yourtheme_menu_item_link($link) {
// Allows for images as menu items. Just supply the path to the image as the title
if (strpos($link['title'], '.png') !== false || strpos($link['title'], '.jpg') !== false || strpos($link['title'], '.gif') !== false) {
$link['title'] = '<img alt="'. $link['description'] .'" title="'. $link['description'] .'" src="'. url($link['title']) .'" />';
$link['localized_options']['html'] = TRUE;
}
return theme_menu_item_link($link);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment