Tested on:
- Drupal 5.x
- Zen theme
- Requirements: JQuery Update
Do you remember my Customize links menu in Drupal mini-howto? You can use it to change text links in image links renaming and customizing theme_links function (from theme.inc) and adding it to your template.php.
On your template.php file, you have something like this:
$imglink_path = path_to_theme() . “/my_zen_subtheme/menu/” . str_replace(” “,”_”,strtolower($link['title']) . $imgsuffix . “.gif”);
$imglink = theme_image($imglink_path, $alt = $link['title'], $title = $link['title'], $attributes = NULL, $getsize = FALSE);
if(empty($imglink))
$imglink = $link['title'];
- Search for images in a defined folder by link title: if link title is “My Nice Link”, a “my_nice_link.gif” image is used.
- Generate HTML code for “my_nice_link.gif”. Note: getsize is set to FALSE to avoid errors on rollover
- If Drupal cannot generate HTML code for image (e.g. file not found) link is rendered as plain text
If you want to add a rollover effect on primary links images, you have to add this JQuery javascript code on page.tpl.php:
<script type="text/javascript">// <![CDATA[
$(document).ready(function()
{
$("#primary a").mouseover(function ()
{
$rollsrc = $(this).children("img").attr("src");
$matches = $rollsrc.match(/_active.gif$/);
if (!$matches) {
$rollON = $rollsrc.replace(/.gif$/,"_active.gif");
$(this).children("img").attr("src", $rollON);
}
});
$("#primary a").mouseout(function ()
{
$(this).children("img").attr("src", $rollsrc);
});
});
// ]]></script>
Where "_active" is the rollover image.
See also:
- Easy, Reusable Image Rollovers with jQuery (JQuery rollover tips used for this mini-howto)
Update:
- A module for Drupal 6.x named Signwriter allows to generate text from images even for menus.
Image may be NSFW.
Clik here to view.

Clik here to view.

Clik here to view.

Clik here to view.
