简体   繁体   English

jQuery漂亮的照片插件不会在库中显示缩略图

[英]jQuery pretty photo plugin doesn't show thumbnails in gallery

I'm using jquery pretty photo plugin as my image gallery. 我正在使用jquery漂亮的照片插件作为我的图片库。 but when I open a photo, it works good but doesn't show the thumbnails, instead shows the default background defined in its css: 但是当我打开一张照片时,效果不错但不显示缩略图,而是显示其css中定义的默认背景:

My Result: 我的结果: 在此输入图像描述

My Desired Result: 我想要的结果: 在此输入图像描述

My HTML: 我的HTML:

<ul class="hover_thumb_wrap">
    <li class="hover_thumb_unit">
        <a rel="prettyPhoto[18]" class="imgwrap" title="Item Title" href="http://placehold.it/800x600" style="cursor: pointer;">
        <img width="50" height="50" alt="Item Thumbnail Alt" class="attachment-50x50" src="http://placehold.it/50x50">
        </a>
    </li>
    <li class="hover_thumb_unit">
        <a rel="prettyPhoto[18]" class="imgwrap" title="Item Title" href="http://placehold.it/400x500" style="cursor: pointer;">
        <img width="50" height="50" alt="Item Thumbnail Alt" class="attachment-50x50" src="http://placehold.it/50x50">
        </a>
    </li>

</ul>

My Javascript: 我的Javascript:

jQuery("#item-wrap a[rel^='prettyPhoto']").prettyPhoto({
            animationSpeed: 'normal', /* fast/slow/normal */
            padding: 15, /* padding for each side of the picture */
            opacity: 0.7, /* Value betwee 0 and 1 */
            showTitle: false, /* true/false */
            allowresize: true, /* true/false */
            counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
            //theme: 'dark_square', /* light_rounded / dark_rounded / light_square / dark_square */
            hideflash: false, /* Hides all the flash object on a page, set to TRUE if flash appears over prettyPhoto */
            modal: false, /* If set to true, only the close button will close the window */
            callback: function() {
                var url = location.href;
                var hashtag = (url.indexOf('#!prettyPhoto')) ? true : false;
                if (hashtag) location.hash = "!";
            } /* Called when prettyPhoto is closed */,
            social_tools : ''
      });

The problem is prettyPhoto validate your image url. 问题是prettyPhoto验证您的图像网址。 Validate image url end with jpg|jpeg|png|gif. 使用jpg | jpeg | png | gif验证图片网址结束。 So solution is: 所以解决方案是:

1: change your image url http://placehold.it/800x600 => http://placehold.it/800x600.jpg 1:更改您的图像网址http://placehold.it/800x600 => http://placehold.it/800x600.jpg

2: Edit file: jquery.prettyPhoto.js (unzip version) line 763: comment this code 2:编辑文件:jquery.prettyPhoto.js(解压缩版本)第763行:注释此代码

if(!pp_images[i].match(/\b(jpg|jpeg|png|gif)\b/gi)){
                    classname = 'default';
                    img_src = '';
                }else{
                    classname = '';
                    img_src = pp_images[i];
                }

and replace with 并替换为

classname = '';
img_src = pp_images[i];

Done! 完成!

<script>
    $(document).ready(function(){
    $("a[rel^='prettyPhoto["18"]']").prettyPhoto({animation_speed:'normal',theme:'pp_default',slideshow:3000, autoplay_slideshow: false});
});

</script>

Add this script in your header file or any other suitable js file. 在头文件或任何其他合适的js文件中添加此脚本。

try adding: 尝试添加:

overlay_gallery:true,
overlay_gallery_max:30

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

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