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

时间:2014-07-24 23:50:57

标签: javascript jquery html css galleria

当我检查元素时,它表示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 for demo的链接是http://jsfiddle.net/zain_aligent/EAVtM/4/

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

1 个答案:

答案 0 :(得分:3)

关键点是数据大属性。定义这样的图库项目。

a href =&#34; ThumbImage.jpg&#34; img src =&#34; ThumbImage.jpg data-big =& #34; LARGEIMAGE.jpg&#34;

<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>