gpt4 book ai didi

javascript - Galleria 使用全尺寸图像而不是缩略图

转载 作者:太空宇宙 更新时间:2023-11-03 23:32:29 25 4
gpt4 key购买 nike

当我检查元素时,它表明 galleria 使用的是全尺寸图像而不是缩略图。

来自 Galleria 文档的示例是 http://galleria.io/docs/getting_started/quick_start/

<div class="galleria">
<a href="/img/large1.jpg"><img src="/img/thumb1.jpg" data-title="My title" data-description="My description"></a>
<a href="/img/large2.jpg"><img src="/img/thumb2.jpg" data-title="Another title" data-description="My <em>HTML</em> description"></a>
</div>

我的代码是

<div class="galleria">
<a href="http://upload.wikimedia.org/wikipedia/commons/thumb/2/2f/3D_Schildersdoek.JPG/812px-3D_Schildersdoek.JPG">
<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/2/2f/3D_Schildersdoek.JPG/220px-3D_Schildersdoek.JPG" alt=""/></a>
<a href="http://upload.wikimedia.org/wikipedia/commons/thumb/0/02/Bitwa_pod_Grunwaldem_Muzeum_Narodowe_05.JPG/800px-Bitwa_pod_Grunwaldem_Muzeum_Narodowe_05.JPG">
<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/0/02/Bitwa_pod_Grunwaldem_Muzeum_Narodowe_05.JPG/300px-Bitwa_pod_Grunwaldem_Muzeum_Narodowe_05.JPG" alt=""/></a>
</div>

用于演示的 jsfiddle 链接是 http://jsfiddle.net/zain_aligent/EAVtM/4/

如何让画廊使用缩略图而不是全尺寸图像?

最佳答案

关键点是data-big属性。像这样定义画廊元素。

a href="ThumbImage.jpg"img src="ThumbImage.jpgdata-big="LARGEIMAGE.jpg"

<div class="galleria">
<a href="ThumbImage.jpg">
<img src="ThumbImage.jpg"
data-big="LargeImage.jpg"
data-title="My title"
data-description="My description"/>
</a>
<a href="ThumbImage.jpg">
<img src="ThumbImage.jpg"
data-big="LargeImage.jpg"
data-title="My title"
data-description="My description"/>
</a>
</div>

尝试下面的更新版本。

<!DOCTYPE html>
<html>

<head>
<link type="text/css" href="galleria/themes/classic/galleria.classic.css" media="screen" rel="stylesheet" />
<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<script src="galleria/galleria-1.3.6.min.js"></script>
</head>

<body>


<div class="galleria">
<a href="http://upload.wikimedia.org/wikipedia/commons/thumb/2/2f/3D_Schildersdoek.JPG/220px-3D_Schildersdoek.JPG">
<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/2/2f/3D_Schildersdoek.JPG/220px-3D_Schildersdoek.JPG"
data-big="http://upload.wikimedia.org/wikipedia/commons/thumb/2/2f/3D_Schildersdoek.JPG/812px-3D_Schildersdoek.JPG"
data-title="My title"
data-description="My description"
/>
</a>
<a href="http://upload.wikimedia.org/wikipedia/commons/thumb/0/02/Bitwa_pod_Grunwaldem_Muzeum_Narodowe_05.JPG/300px-Bitwa_pod_Grunwaldem_Muzeum_Narodowe_05.JPG">
<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/0/02/Bitwa_pod_Grunwaldem_Muzeum_Narodowe_05.JPG/300px-Bitwa_pod_Grunwaldem_Muzeum_Narodowe_05.JPG"
data-big="http://upload.wikimedia.org/wikipedia/commons/thumb/0/02/Bitwa_pod_Grunwaldem_Muzeum_Narodowe_05.JPG/800px-Bitwa_pod_Grunwaldem_Muzeum_Narodowe_05.JPG"
data-title="Another title"
data-description="My <em>HTML</em> description"
/>
</a>
</div>



<script type="text/javascript">
$( document ).ready(function() {
Galleria.loadTheme('galleria/themes/classic/galleria.classic.min.js');

$('.galleria').galleria({
width: 350,
height: 315,
thumbCrop: "height",
lightbox: true
});
Galleria.run('.galleria');
});
</script>

</body>
</html>

关于javascript - Galleria 使用全尺寸图像而不是缩略图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24945862/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com