0

我需要为我的图像添加一个标题,以便 flexslider 将其显示为标题。但是我不知道如何在 drupal 7 中为图像字段添加标题。我尝试将字段添加到文件类型图像 admin/config/media/file-types/manage/image/display 但它不接受我在表单中输入的内容。

4

2 回答 2

1

如果您创建自己的模板,请复制原始模板并使用 alt 或标题字段添加打印标题标题:

<div id="slider" class="flexslider">
<ul class="slides">
  <?php foreach ($items as $img):?>

  <li><?php print render ($img) ; ?>

  <?php if (!empty($img['#item']['alt'])) { ?>
    <p class="title-caption"><?php print $img['#item']['alt']; ?></p>
  <?php } ?>

  </li>

  <?php endforeach; ?>
</ul>
</div>


<?php 
  $counter = count($items);
  if($counter > 0){ ?>
  <div id="carousel" class="flexslider">
    <ul class="slides">
    <?php foreach ($items as $img): ?>
      <li><?php print render($img); ?></li>
    <?php endforeach; ?>
    </ul>
 </div>
<?php  }

然后添加到你的CSS:

.title-caption {
position: absolute;
width: 99%;
padding: 10px;
bottom: 0px;
color: #fff;
text-shadow: 0 -1px 0 rgba(0,0,0,.5);
font-size: 20px;
line-height: 28px;
margin: 5px;
}
于 2016-05-09T11:16:31.573 回答
0

有人在这里为我回答了这个问题http://drupal.org/node/1067620#comment-6994238 您必须编辑内容类型,然后编辑图像,如果向下滚动,则会出现“启用标题”复选框

于 2013-01-29T14:27:41.207 回答