Created
August 1, 2010 12:08
-
-
Save zerolab/503290 to your computer and use it in GitHub Desktop.
Custom Drupal menu items images
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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