首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在.galleria中添加替代文本?

问如何在.galleria中添加替代文本?
EN

Stack Overflow用户
提问于 2014-09-04 13:18:54
回答 2查看 1.5K关注 0票数 7

如何使用jquery.galleria.js在缩略图和大图像中添加替代文本?

​

代码语言:javascript
复制
$(window).load(function() {
      Galleria.loadTheme('http://www.bulogjatim.com/wp-content/themes/duotive-fortune/js/jquery.galleria.template.js');
      $("#galleria").galleria({
        width: 880,
        height: 439,
        transition: 'fadeslide'
      });
    );
代码语言:javascript
复制
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="galleria" class="galleria-wrapper">
  <a class="image-wrapper" href="http://veithen.github.io/images/icon-stackoverflow.svg">
    <img src="http://veithen.github.io/images/icon-stackoverflow.svg" />
  </a>
</div>

​

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-09-04 14:19:07

您可以通过向您的data标记添加一个img属性来做到这一点。

例如,data-layer将在您的图像上写一个标题。

示例用法:

代码语言:javascript
复制
    <img data-layer="my caption" src="image.jpg" >

来源:https://galleriajs.github.io/docs/references/data.html

要向galleria中的图像添加用于SEO优化的alt属性:

html:<img alt="My SEO optimized alt tag" src="image.jpg" >

将它们添加到galleria中的图片中:

代码语言:javascript
复制
$(document).ready(function() {
  Galleria.loadTheme('/js/jquery.galleria.template.js');
  Galleria.run('.galleria');
  Galleria.ready(function() {
    this.bind('image', function(e) {
      // add alt to big image
      e.imageTarget.alt = e.galleriaData.original.alt;
    });
    this.bind('thumbnail', function(e) {
      // add alt to thumbnails image
      e.thumbTarget.alt = e.galleriaData.original.alt;
    });
  });
});

我希望这能帮助你在路上。

来源:http://support.galleria.io/discussions/problems/645-alt-tags-missing-from-folio-thumbnails

工作示例:http://embed.plnkr.co/nnTFw5SkUYeYZP6I9hqb/preview

  • 感谢@gsinha在我的示例代码中报告了一个bug并提供了一个解决方案。
票数 8
EN

Stack Overflow用户

发布于 2014-09-04 13:24:33

向对象添加文本:

代码语言:javascript
复制
$("#galleria").append("your text here");

并将HTML对象设置为图像:

代码语言:javascript
复制
$("#id").html('<img="path/to/your/file.png"/>); 
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25666589

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档