简体   繁体   English

如何在Drupal中为图像添加工具提示? 使用自定义模板

[英]How to add tool tip for image in Drupal? Using custom template

I'm using Drupal 6.x. 我正在使用Drupal6.x。 This is my code on my node-product.tpl.php template. 这是我在node-product.tpl.php模板上的代码。 I've created a custom jquery gallery for the products. 我为产品创建了一个自定义的jquery画廊。 It works great, but I'm just missing tool tips from my images (both large and small thumbnails). 效果很好,但我只是在图像中缺少工具提示(大和小缩略图)。 To upload images I'm using a CCK field named field_images. 要上传图像,我使用的是名为field_images的CCK字段。 There I input the image titles when I upload the images. 上传图像时,我在那里输入图像标题。 How can I add the tool tip code snippet to make it work? 如何添加工具提示代码片段以使其正常工作?

<div class="product-large">
<img src="/sites/default/files/imagecache/360x280/<?php print $node->field_images[0]['filename']; ?>" />
</div>

<div class="product-small">
   <?php
           // get all images
            foreach ($node->field_images as $images) {
        ?>
   <img src="/sites/default/files/imagecache/120x90/<?php print $images['filename']; ?>" rel="/sites/default/files/imagecache/360x280/<?php print $images['filename']; ?>" />
    <?php   
        }
        ?>
</div>

Thanks much appreciated! 非常感谢!

Chris 克里斯

The "tooltip" is a result of the title HTML attribute. “工具提示”是title HTML属性的结果。 You'll want to add title="foo" to your img tag. 您需要将title="foo"添加到您的img标签中。

Perhaps: <img src="/sites/default/files/imagecache/120x90/<?php print $images['filename']; ?>" rel="/sites/default/files/imagecache/360x280/<?php print $images['data']['filename']; ?>" title="<?php print $images['title']; ?>"/> for the second image and similarly $node->field_images[0]['data']['title'] for the first. 也许: <img src="/sites/default/files/imagecache/120x90/<?php print $images['filename']; ?>" rel="/sites/default/files/imagecache/360x280/<?php print $images['data']['filename']; ?>" title="<?php print $images['title']; ?>"/>用于第二个图像,类似地, $node->field_images[0]['data']['title']首先。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM